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)
commitc5ec04f24ead4c5c5418fedf50d1ef77ba8620cd
tree1c7864228f07d45840e1e818784ab0be5934f2c9
parent1203e82d9b81798d4ad25f19b59c8943446e0f8c
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>
(This used to be ctdb commit 4e0f1971792c9431d8d51dc57d54ecc9e4576dd5)
ctdb/client/ctdb_client.c
ctdb/include/ctdb_client.h