s3:dbwrap_ctdb: exit early when nothing has been written in transaction_commit.
authorMichael Adam <obnox@samba.org>
Wed, 13 Jan 2010 22:53:54 +0000 (23:53 +0100)
committerMichael Adam <obnox@samba.org>
Fri, 12 Feb 2010 22:12:12 +0000 (23:12 +0100)
This skips update of the __db_sequence_number__ record when nothing else has
been written. There are transactions that are just openend and then nothing
is written until transaction_commit is called. This is for instance the case
with registry initialization routines: They start a transaction and only
write somthing when the registry has not been initialized yet.
So this change will skip many db_seqnum bumps and TRANS3_COMMIT roundtrips.

Michael

source3/lib/dbwrap_ctdb.c

index c0b5fd51ed540b49e645b50748543026e625134b..79c4c0ce420f0cdd28085999d99ba9ed2ba654d0 100644 (file)
@@ -763,6 +763,15 @@ static int db_ctdb_transaction_commit(struct db_context *db)
                return 0;
        }
 
                return 0;
        }
 
+       if (h->m_write == NULL) {
+               /*
+                * No changes were made, so don't change the seqnum,
+                * don't push to other node, just exit with success.
+                */
+               ret = 0;
+               goto done;
+       }
+
        DEBUG(5,(__location__ " Commit transaction on db 0x%08x\n", ctx->db_id));
 
        /*
        DEBUG(5,(__location__ " Commit transaction on db 0x%08x\n", ctx->db_id));
 
        /*
@@ -790,11 +799,6 @@ static int db_ctdb_transaction_commit(struct db_context *db)
        }
 
 again:
        }
 
 again:
-       if (h->m_write == NULL) {
-               /* no changes were made, potentially after a retry */
-               goto done;
-       }
-
        /* tell ctdbd to commit to the other nodes */
        rets = ctdbd_control_local(messaging_ctdbd_connection(),
                                   CTDB_CONTROL_TRANS3_COMMIT,
        /* tell ctdbd to commit to the other nodes */
        rets = ctdbd_control_local(messaging_ctdbd_connection(),
                                   CTDB_CONTROL_TRANS3_COMMIT,