Journal (Transactions) Class
gxdJournal makes writes to several database files all or nothing, and finishes the committed ones after a crash.
Overview
Attach every file a transaction writes (gxDatabase files, gxBtree indexes, a gxVectorIndex's Database()), then Begin(), write, and Commit() or Rollback(). The journal records each batch of pages and its commit before the pages reach the files, so after a crash the next Open() (or Recover()) finishes every committed batch and drops the rest. Open the journal before the files.
Replication: 7.4 replicates objects with gxObjRepl (gxobjrepl.h), which uses the journal's Open(), Recover() and RecoverError(). The 7.3 ship log (EnableShipLog(), EnableObjectNotes()) was removed in 7.4 beta 5 with gxrepl page shipping: a program that called it drops the call. Readers in another process take a gxdJournalReadLock to see whole batches only. The example: journal_recovery.
Transactions
gxDatabaseError Open(const char *jname) / Close()Recovers, then opens the journal; Close() rolls back an open batch or checkpoints, and truncates the journal file.
gxDatabaseError Attach(gxDatabase *f) / Attach(gxBtree *btx) / Attach(BtreeCache *cache)Adds a file to the journal's transactions.
gxDatabaseError Begin() / Commit(int durable = 1) / Rollback()Starts a batch, commits it (synced when durable), or undoes it (a gxVectorIndex then needs Reload()).
gxDatabaseError Checkpoint()Writes the committed pages to the files and empties the journal.
static gxDatabaseError Recover(const char *jname, unsigned long *recovered = 0, int mark = 1) / unsigned long Recovered() constFinishes the committed batches a stopped writer left; the count of batches replayed by Open(). mark is ignored since 7.4 beta 5.
static const char *RecoverError()Why this thread's last Recover() failed, or "".
void SetWriteMode(gxdJournalWriteMode mode) / void SetWriteLock(int lock)When committed pages reach the files (write through or write back); the write lock that gxdJournalReadLock readers wait for.