-
Notifications
You must be signed in to change notification settings - Fork 40
Concurrency and conflict check
mvsqlite exposes optimistic concurrency. Transaction start is a lock-free operation, and conflicts are checked during commit. If a conflict happens, SQLITE_BUSY
is returned for the COMMIT
statement.
There are two types of conflict check mechanisms supported by mvsqlite:
- Page-level conflict check (PLCC), for small (<= 2000 pages/~15.6 MiB with 8KiB pages read) transactions.
- Database-level conflict check (DLCC), for large transactions.
At commit time, PLCC checks whether any pages read by the current transaction has been written to by another transaction. If this happens, a conflict is reported and the current transaction is aborted.
PLCC can reduce conflict and allow concurrent writers, but has very fine-grained conflict ranges and may exceed FDB's transaction size limit when applying the commit. Therefore, PLCC only works for small transactions, and larger ones fall back to DLCC.
DLCC is much simpler: it just checks whether any change happened on the database during the current transaction's duration. If any change happened, it is treated as a conflict, and the current transaction is aborted.