slony1-bugs at lists.slony.info slony1-bugs at lists.slony.info
Mon Nov 16 14:39:30 PST 2009
http://www.slony.info/bugzilla/show_bug.cgi?id=102

           Summary: slonik hangs when doing a failover
           Product: Slony-I
           Version: devel
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: medium
         Component: slonik
        AssignedTo: slony1-bugs at lists.slony.info
        ReportedBy: msquires at whitepages.com
                CC: slony1-bugs at lists.slony.info
   Estimated Hours: 0.0


If you have a configuration with 1 master and 2 or more slaves, and you have
all paths defined, slonik can hang during a failover.

In src/slonik/slonik.c, the slonik_failed_node function queries the sl_nodelock
table on each node to find the listener process responsible for that node and
stores it in nodeinfo.

Later in the function it loops through all the nodes, checking to see if the
listener responsible for that node has exited so it knows that slon has
restarted on that node.

Unfortunately, the query it uses just counts the number of processes that are
not that original pid. It obviously is expecting only one entry in the result
set (i.e., the replacement listener). If there are other listeners for other
nodes running on that node (as is the case when a second slave has a path
defined, for example), then that query may never return exactly 1.

The fix is to add the node number to the query, since then it finds the number
of processes that aren't the old listener that are assigned to that node. When
there is exactly 1 of those then the slon has restarted.




Index: slony1-engine/src/slonik/slonik.c
===================================================================
--- slony1-engine.orig/src/slonik/slonik.c      2009-11-16 12:15:23.000000000
-0800
+++ slony1-engine/src/slonik/slonik.c   2009-11-16 12:34:35.000000000 -0800
@@ -2618,9 +2618,13 @@

                        slon_mkquery(&query,
                                                 "select nl_backendpid from
\"_%s\".sl_nodelock "
-                                                "    where nl_backendpid <>
%d; ",
+                                                "    where nl_backendpid <> %d
"
+                                                "    and nl_nodeid =
\"_%s\".getLocalNodeId('_%s');",
                                                 stmt->hdr.script->clustername,
-                                                nodeinfo[i].slon_pid);
+                                                nodeinfo[i].slon_pid,
+                                                stmt->hdr.script->clustername,
+                                                stmt->hdr.script->clustername
+                                                );
                        res1 = db_exec_select((SlonikStmt *) stmt,
nodeinfo[i].adminfo, &query);
                        if (res1 == NULL)
                        {


-- 
Configure bugmail: http://www.slony.info/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
You are the assignee for the bug.


More information about the Slony1-bugs mailing list