1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

Port Volkers deadlock avoidance patch to HEAD.

This patch ensures that we lock all non-notify related databases first and
then the notify databases to avoiud a deadlock where samba needs to lock records on two databases at once (and notify being the second database).

Newer versions of samba would instead use the set-db-prio control to set this explicitely on a database per database basis instead of relying on  hardcoded database names. This patch will be reverted in the future when all updated versions of samba has been pushed out.

(This used to be ctdb commit 70e7781df1f118a0e2632a9c634f3fd388fa6c8c)
This commit is contained in:
Ronnie Sahlberg 2009-10-14 08:17:49 +11:00
parent 98b5caf003
commit 3ac5a52969
2 changed files with 41 additions and 0 deletions

View File

@ -33,10 +33,31 @@
static int ctdb_lock_all_databases(struct ctdb_context *ctdb, uint32_t priority)
{
struct ctdb_db_context *ctdb_db;
/* REMOVE later */
/* This double loop is for backward compatibility and deadlock
avoidance for old samba versions that not yet support
the set prio call.
This code shall be removed later
*/
for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
if (ctdb_db->priority != priority) {
continue;
}
if (strstr(ctdb_db->db_name, "notify") != NULL) {
continue;
}
DEBUG(DEBUG_INFO,("locking database 0x%08x priority:%u %s\n", ctdb_db->db_id, ctdb_db->priority, ctdb_db->db_name));
if (tdb_lockall(ctdb_db->ltdb->tdb) != 0) {
return -1;
}
}
for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
if (ctdb_db->priority != priority) {
continue;
}
if (strstr(ctdb_db->db_name, "notify") == NULL) {
continue;
}
DEBUG(DEBUG_INFO,("locking database 0x%08x priority:%u %s\n", ctdb_db->db_id, ctdb_db->priority, ctdb_db->db_name));
if (tdb_lockall(ctdb_db->ltdb->tdb) != 0) {
return -1;

View File

@ -44,10 +44,30 @@ static int ctdb_lock_all_databases_mark(struct ctdb_context *ctdb, uint32_t prio
DEBUG(DEBUG_ERR,("Attempt to mark all databases locked when not frozen\n"));
return -1;
}
/* The dual loop is a woraround for older versions of samba
that does not yet support the set-db-priority/lock order
call. So that we get basic deadlock avoiidance also for
these old versions of samba.
This code will be removed in the future.
*/
for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
if (ctdb_db->priority != priority) {
continue;
}
if (strstr(ctdb_db->db_name, "notify") != NULL) {
continue;
}
if (tdb_lockall_mark(ctdb_db->ltdb->tdb) != 0) {
return -1;
}
}
for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
if (ctdb_db->priority != priority) {
continue;
}
if (strstr(ctdb_db->db_name, "notify") == NULL) {
continue;
}
if (tdb_lockall_mark(ctdb_db->ltdb->tdb) != 0) {
return -1;
}