DBMS Integration
Sophia support special work modes which can be used to support external Write-Ahead Log: log.enable and sophia.recover.
Two-Phase Recover
In this mode Sophia processes transactions to ensure that they were not already commited.
After second sp_open() Sophia starts environment.
- env = sp_env()
- sophia.recover = 2
- log.enable = 0
- sp_open(env) start in recovery mode, compaction not started
- start defining and recovering databases
- start replaying transactions from external WAL
- sp_setint(transaction, "lsn", lsn) forge transaction lsn before commit
- sp_commit(transaction) every commit ensures that data were not previously written to disk
- sp_open(env) second time starts in default mode
This mode can be helpful for Sophia integration into other database management system, which supports its own Write-Ahead Log.
N-Phase Recover
This recovery mode allows to switch Sophia into recovery mode and back on the fly.
- env = sp_env()
- sophia.recover = 3
- log.enable = 0
- sp_open(env) start in default mode with thread-pool run.
- usual transaction processing
- sp_open(env) switch to recovery mode
- start replaying transactions from external source
- sp_setint(transaction, "lsn", lsn) forge transaction lsn before commit
- sp_commit(transaction) every commit ensures that data were not previously written to disk
- sp_open(env) again switch Sophia back to default mode.
Steps from 4-9 can be repeated any time.
This mode can be helpful for Sophia integration with most of a Replication/JOIN technologies.