client: Reimplement persistent transaction code using TRANS3_COMMIT
authorAmitay Isaacs <amitay@gmail.com>
Mon, 23 Sep 2013 08:30:04 +0000 (18:30 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 4 Oct 2013 05:46:15 +0000 (15:46 +1000)
commit4e0f1971792c9431d8d51dc57d54ecc9e4576dd5
tree700d5ebf2ea1d6223d3987975c8f6d55fe337ed4
parent40589ae5259880431f358250c1f0d07bcaa21d1f
client: Reimplement persistent transaction code using TRANS3_COMMIT

Implementing persistent trasnaction code from Samba.

Persistent transaction code was reimplemented in Samba using g_lock.tdb
to hold transaction locks and using TRANS3_COMMIT control.

Implementation details:

1. When starting a transaction, create a record with "transaction-<dbid>"
   as key and store current server_id in the structure.

2. If a record already exists, some other client has already started a
   transaction.  Verify that the process corresponding to server_id stored
   in the record really exists or it's a stale record and overwrite it.

3. All modifications to the actual persistent database are stored in a
   marshal buffer.

4. When transaction is committed, read the sequence number of the
   persistent database and increment it.  Sequence number record is also
   stored in the marshal buffer.

5. Send the changed records (marshal buffer) in TRANS3_COMMIT control
   to all the active nodes.

6. If all controls succeed, verify that the sequence number has been
   incremented.  Commit is successful.  If any of the controls fail,
   abort the transaction.

7. In case sequence number has not yet been incremented, then database
   recovery has been triggered.  So repeat from step 5.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
client/ctdb_client.c
include/ctdb_client.h