evilsocket / opensnitch

OpenSnitch is a GNU/Linux interactive application firewall inspired by Little Snitch.
GNU General Public License v3.0
10.78k stars 503 forks source link

Diagnose DB file mode "PRAGMA synchronous NORMAL" failure #1014

Closed lainedfles closed 1 year ago

lainedfles commented 1 year ago

Throughout testing #1011 I'd realized that while PRAGMA synchronous = NORMAL is executed, it isn't updated and remains at the FULL value. Execution of the statement manually via the sqlite3 CLI utility (version 3.42.0) succeeds. Can anyone else confirm this behavior? I'm using PyQt v5.15.9 with qt5 v5.15.10.

According to the official documentation, NORMAL can be beneficial when durability isn't critical (in my case it's not):

In WAL mode when synchronous is NORMAL (1), the WAL file is synchronized before each checkpoint and the database file is synchronized after each completed checkpoint and the WAL file header is synchronized when a WAL file begins to be reused after a checkpoint, but no sync operations occur during most transactions. With synchronous=FULL in WAL mode, an additional sync operation of the WAL file happens after each transaction commit. The extra WAL sync following each transaction helps ensure that transactions are durable across a power loss. Transactions are consistent with or without the extra syncs provided by synchronous=FULL. If durability is not a concern, then synchronous=NORMAL is normally all one needs in WAL mode.

https://github.com/evilsocket/opensnitch/blob/57838e821e073f77d92afe26f7d998bca3831ce7/ui/opensnitch/database/__init__.py#L245C13-L245C13

gustavo-iniguez-goya commented 1 year ago

Apparently some pragmas are only valid during the connection lifespan: https://sqlite-users.sqlite.narkive.com/e3iOB8Z3/sqlite-which-pragmas-are-persistent#post4

lainedfles commented 1 year ago

Apparently some pragmas are only valid during the connection lifespan: https://sqlite-users.sqlite.narkive.com/e3iOB8Z3/sqlite-which-pragmas-are-persistent#post4

That makes perfect sense, it is setting NORMAL but only for the session/connection. My bad, thanks again for everything!