If the freeze child is already created in ctdb_start_freeze(), then it indicates
that the child process has not yet obtained the locks. This may be because
another process has locked the databases and has not yet released the locks.
In this case, invoke a helper script defined by environmental variable
CTDB_DEBUG_LOCKS, to log information about locks.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit
e80b2c15bf8c8fb5c3793acfebbe09d3cdd617b7)
return 0;
}
+/*
+ * Run an external script to check if there is a deadlock situation
+ */
+static void ctdb_debug_locks(void)
+{
+ const char *cmd = getenv("CTDB_DEBUG_LOCKS");
+ int pid;
+
+ if (cmd == NULL) {
+ return;
+ }
+
+ pid = fork();
+
+ /* Execute only in child process */
+ if (pid == 0) {
+ execl(cmd, cmd, NULL);
+ }
+}
+
/*
start the freeze process for a certain priority
*/
ctdb->freeze_handles[priority] = ctdb_freeze_lock(ctdb, priority);
CTDB_NO_MEMORY(ctdb, ctdb->freeze_handles[priority]);
ctdb->freeze_mode[priority] = CTDB_FREEZE_PENDING;
+ } else {
+ /* The previous free lock child has not yet been able to get locks.
+ * Invoke debugging script */
+ ctdb_debug_locks();
}
return 0;