Files
chatmail-core/src
iequidoo e767d84bea Switch to DEFERRED transactions
We do not make all transactions
[IMMEDIATE](https://www.sqlite.org/lang_transaction.html#deferred_immediate_and_exclusive_transactions)
for more parallelism -- at least read transactions can be made DEFERRED to run in parallel
w/o any drawbacks. But if we make write transactions DEFERRED also w/o any external locking,
then they are upgraded from read to write ones on the first write statement. This has some
drawbacks:
- If there are other write transactions, we block the thread and the db connection until
  upgraded. Also if some reader comes then, it has to get next, less used connection with a
  worse per-connection page cache.
- If a transaction is blocked for more than busy_timeout, it fails with SQLITE_BUSY.
- Configuring busy_timeout is not the best way to manage transaction timeouts, we would
  prefer it to be integrated with Rust/tokio asyncs. Moreover, SQLite implements waiting
  using sleeps.
- If upon a successful upgrade to a write transaction the db has been modified by another
  one, the transaction has to be rolled back and retried. It is an extra work in terms of
  CPU/battery.
- Maybe minor, but we lose some fairness in servicing write transactions, i.e. we service
  them in the order of the first write statement, not in the order they come.
The only pro of making write transactions DEFERRED w/o the external locking is some
parallelism between them. Also we have an option to make write transactions IMMEDIATE, also
w/o the external locking. But then the most of cons above are still valid. Instead, if we
perform all write transactions under an async mutex, the only cons is losing some
parallelism for write transactions.
2023-02-28 15:05:47 -03:00
..
2023-02-24 13:23:17 +00:00
2023-02-26 18:48:32 +00:00
2023-02-26 21:27:21 +00:00
2023-02-15 21:56:33 +00:00
2023-02-23 12:55:43 +00:00
2023-02-14 21:33:02 +00:00
2023-02-22 16:03:20 +01:00
2023-01-30 11:50:11 +03:00
2023-02-25 15:37:10 +01:00
2023-01-30 11:50:11 +03:00
2023-01-30 11:50:11 +03:00
2023-02-23 12:55:43 +00:00
2023-02-26 22:31:53 +00:00
2023-01-30 11:50:11 +03:00
2023-02-22 16:03:20 +01:00
2023-01-30 11:50:11 +03:00
2023-02-15 21:56:33 +00:00
2022-12-28 19:01:48 +00:00
2023-02-15 21:56:33 +00:00
2023-02-26 22:31:53 +00:00
2023-02-28 15:05:47 -03:00
2023-02-26 22:31:53 +00:00
2023-02-28 15:05:47 -03:00
2023-02-24 13:23:17 +00:00
2023-02-15 21:56:33 +00:00
2023-01-30 11:50:11 +03:00
2023-02-22 15:10:33 +00:00
2023-02-13 14:01:24 +00:00
2023-02-15 21:56:33 +00:00
2023-02-23 12:55:43 +00:00
2023-02-24 17:49:08 +00:00
2023-02-28 15:05:47 -03:00
2023-02-26 22:31:53 +00:00
2023-02-24 13:23:17 +00:00
2023-02-28 15:05:47 -03:00
2023-02-15 21:56:33 +00:00
2023-01-30 11:50:11 +03:00
2023-02-14 10:57:57 +00:00
2022-07-05 14:20:01 +02:00
2023-02-14 21:33:02 +00:00
2023-02-28 15:05:47 -03:00