Policy_rules rows are not deleted in database #1430

Closed
opened 2025-11-20 05:30:13 -05:00 by saavagebueno · 5 comments
Owner

Originally created by @maigl on GitHub (Nov 19, 2024).

Describe the problem

I noticed that for every policy I get one entry in the policies table and one entry in the policy_rules table. If I delete the policy, the entry from the policies table is removed, but not from the policy_rules table. As I create and delete many many policies I have a table that grows and grows.

To Reproduce

  1. create a policy
  2. check size of policies table, it grows by 1
  3. check size of policy_rules table, it grows by 1
  4. delete policy
  5. check size of policies table, it shrinks by 1
  6. check size of policy_rules table, it NOT shrinks by 1

Expected behavior

I expect to not have a table that grows forever.

Are you using NetBird Cloud?

no

NetBird version

0.32.0

Originally created by @maigl on GitHub (Nov 19, 2024). **Describe the problem** I noticed that for every policy I get one entry in the `policies` table and one entry in the `policy_rules` table. If I delete the policy, the entry from the `policies` table is removed, but not from the `policy_rules` table. As I create and delete many many policies I have a table that grows and grows. **To Reproduce** 1. create a policy 2. check size of policies table, it grows by 1 3. check size of policy_rules table, it grows by 1 4. delete policy 5. check size of policies table, it shrinks by 1 6. check size of policy_rules table, it NOT shrinks by 1 **Expected behavior** I expect to not have a table that grows forever. **Are you using NetBird Cloud?** no **NetBird version** 0.32.0
saavagebueno added the management-servicewaiting-feedback labels 2025-11-20 05:30:13 -05:00
Author
Owner

@mlsmaycon commented on GitHub (Nov 19, 2024):

@bcmmbaga what do you think might be causing that?

@mlsmaycon commented on GitHub (Nov 19, 2024): @bcmmbaga what do you think might be causing that?
Author
Owner

@bcmmbaga commented on GitHub (Nov 19, 2024):

The issue is likely caused by SQLite not enforcing foreign key constraints.

You can check if foreign key enforcement is enabled in your SQLite database:

PRAGMA foreign_keys;

If the result is 0, foreign key constraints are not being enforced.

@bcmmbaga commented on GitHub (Nov 19, 2024): The issue is likely caused by SQLite not enforcing foreign key constraints. You can check if foreign key enforcement is enabled in your SQLite database: `PRAGMA foreign_keys;` If the result is 0, foreign key constraints are not being enforced.
Author
Owner

@maigl commented on GitHub (Nov 20, 2024):

.. right

/var/lib/netbird $ sqlite3 store.db 
SQLite version 3.45.3 2024-04-15 13:34:05
Enter ".help" for usage hints.
sqlite> PRAGMA foreign_keys;
0

should I need to change sqlite settings myself? Can I just safely do that? I thought maybe there is some other good reasons why the policy_rules are kept?!

@maigl commented on GitHub (Nov 20, 2024): .. right ``` /var/lib/netbird $ sqlite3 store.db SQLite version 3.45.3 2024-04-15 13:34:05 Enter ".help" for usage hints. sqlite> PRAGMA foreign_keys; 0 ``` should I need to change sqlite settings myself? Can I just safely do that? I thought maybe there is some other good reasons why the policy_rules are kept?!
Author
Owner

@nazarewk commented on GitHub (Apr 28, 2025):

Hello @maigl,

We're currently reviewing our open issues and would like to verify if this problem still exists in the latest NetBird version.

Could you please confirm if the issue is still there?

We may close this issue temporarily if we don't hear back from you within 2 weeks, but feel free to reopen it with updated information.

Thanks for your contribution to improving the project!

@nazarewk commented on GitHub (Apr 28, 2025): Hello @maigl, We're currently reviewing our open issues and would like to verify if this problem still exists in the [latest NetBird version](https://github.com/netbirdio/netbird/releases). Could you please confirm if the issue is still there? We may close this issue temporarily if we don't hear back from you within **2 weeks**, but feel free to reopen it with updated information. Thanks for your contribution to improving the project!
Author
Owner

@mlsmaycon commented on GitHub (Jun 1, 2025):

closing issue due to no recent feedback. Feel free to open a new one if the issue persist or reopen if this was a feature request.

@mlsmaycon commented on GitHub (Jun 1, 2025): closing issue due to no recent feedback. Feel free to open a new one if the issue persist or reopen if this was a feature request.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#1430