Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum days of events to keep is not working (no events are removed) #844

Closed
BetweenTheKeyboardAndChair opened this issue Feb 11, 2023 · 1 comment

Comments

@BetweenTheKeyboardAndChair

Bug: Old events are not being removed from the events UI tab.

The UI setting preferences for the database are:
Database type: In memory

  • [check] Maximum days of events to keep [1] days
  • Minutes between event purges [60] minutes

System info: Ubuntu 20.04.1 LTS (focal), ucin 5.4.0-135-generic
opensnitch/now 1.6.0-rc.4-1 amd64 [installed,local]
python3-opensnitch-ui/now 1.6.0-rc.4-1 all [installed,local]
protobuf: 3.6.1
grpc: 1.37.1

To Reproduce
Start opensnitch and the UI, and let it run. No events have been removed since the process was started 2 weeks ago. i.e. If I reverse sort events by time on the events tab, I see events from 1/26/22.

@gustavo-iniguez-goya
Copy link
Collaborator

gustavo-iniguez-goya commented Feb 12, 2023

Hi @BetweenTheKeyboardAndChair ,

I've been analyzing this issue, and I've found a solution. I'll test it for a couple of days to see if there's any downside.

The problem is how QsqlDatabase works from different threads:

A connection can only be used from within the thread that created it.

In order to access a database from different threads you create a new QsqlDatabase connection to the DB specifying the DB name/file.
With DBs written to the disk, the database file/name is always the same (say /tmp/file.db).

But with in-memory databases, whenever you create a new connection with :memory:, it always create a new in-memory DB, so the DB is empty for the cleaner task, and that's why it was not deleting old events.

gustavo-iniguez-goya added a commit that referenced this issue Feb 26, 2023
In 5b5e271 we added support for
in-memory cached DB, to allow delete old events from memory (#844).

Unfortunately, on some systems this URI (file::memory:?cache=shared)
creates a file on disk on user's home.

This file is in the end a DB, so if users want to delete old events,
they'll have to save events to disk.

On the other hand, when in-memory DB is selected, we now disable the
option to delete old events from memory.

Closes #857
gustavo-iniguez-goya added a commit that referenced this issue Nov 3, 2023
Not deleting events from in-memory db can lead to a high mem usage under
certain scenarios.

Previous attempt to solve this issue wrote events to disk in a temporal
file (when using file::memory:?cache=shared).

Related issues: #844 #857

Closes: #1030
gustavo-iniguez-goya added a commit that referenced this issue Nov 6, 2023
Not deleting events from in-memory db can lead to a high mem usage under
certain scenarios.

Previous attempt to solve this issue wrote events to disk in a temporal
file (when using file::memory:?cache=shared).

Related issues: #844 #857

Closes: #1030
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants