summaryrefslogtreecommitdiffstats
path: root/ctdb
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2009-10-29 22:20:38 +0100
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2009-10-30 22:01:16 +1100
commit118185670d5bd871987887e4096b16a90c3d5426 (patch)
treecdba370b8b52a300fb86e6fd73f25f8edac7b683 /ctdb
parentc2855a11a8a9e9e1a1c3abc18b42412cb41da653 (diff)
downloadsamba-118185670d5bd871987887e4096b16a90c3d5426.tar.gz
samba-118185670d5bd871987887e4096b16a90c3d5426.tar.xz
samba-118185670d5bd871987887e4096b16a90c3d5426.zip
client: fix a race in the local race condition fix in transaction_start
The gap that remained is between checking whether a transaction commit is in progress and taking the lock. Now we first take the lock and then check whether a transaction commit is in progress. If so, we release the lock, wait for one second and retry. Michael (This used to be ctdb commit b95524c08bf12914120cb6c818ecc1c99738fe37)
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/client/ctdb_client.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index b03e0f85fd..ae01638665 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -3213,6 +3213,15 @@ static int ctdb_transaction_fetch_start(struct ctdb_transaction_handle *h)
}
again:
+ tmp_ctx = talloc_new(h);
+
+ rh = ctdb_fetch_lock(ctdb_db, tmp_ctx, key, NULL);
+ if (rh == NULL) {
+ DEBUG(DEBUG_ERR,(__location__ " Failed to fetch_lock database\n"));
+ talloc_free(tmp_ctx);
+ return -1;
+ }
+
status = ctdb_ctrl_transaction_active(ctdb_db->ctdb,
CTDB_CURRENT_NODE,
ctdb_db->db_id);
@@ -3220,18 +3229,11 @@ again:
DEBUG(DEBUG_NOTICE, (__location__ " transaction is active "
"on db_id[0x%08x]. waiting for 1 second\n",
ctdb_db->db_id));
+ talloc_free(tmp_ctx);
sleep(1);
goto again;
}
- tmp_ctx = talloc_new(h);
-
- rh = ctdb_fetch_lock(ctdb_db, tmp_ctx, key, NULL);
- if (rh == NULL) {
- DEBUG(DEBUG_ERR,(__location__ " Failed to fetch_lock database\n"));
- talloc_free(tmp_ctx);
- return -1;
- }
/*
* store the pid in the database:
* it is not enough that the node is dmaster...