Make failover in progress check more aggressively.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Wed, 22 May 2019 22:34:03 +0000 (07:34 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Wed, 22 May 2019 22:41:53 +0000 (07:41 +0900)
In pool_virtual_master_db_node_id() the case when session context is
not available was not covered by the failover in progress checking
because I thought it'd be too aggressive. However a report from field
showed that that could happen while authenticating a client (and it
causes a segfault). So I decided to move the check to beginning of the
function to cover the case.

src/context/pool_query_context.c

index d022841ed29e92397bf978d29bd7beb9aedba55d..8a986dbd2db6e273f81be67871d6c87e79d82fe0 100644 (file)
@@ -299,12 +299,6 @@ int pool_virtual_master_db_node_id(void)
 {
        POOL_SESSION_CONTEXT *sc;
 
-       sc = pool_get_session_context(true);
-       if (!sc)
-       {
-               return REAL_MASTER_NODE_ID;
-       }
-
        /*
         * Check whether failover is in progress. If so, just abort this session.
         */
@@ -319,6 +313,12 @@ int pool_virtual_master_db_node_id(void)
                child_exit(POOL_EXIT_AND_RESTART);
        }
 
+       sc = pool_get_session_context(true);
+       if (!sc)
+       {
+               return REAL_MASTER_NODE_ID;
+       }
+
        if (sc->in_progress && sc->query_context)
        {
                int node_id = sc->query_context->virtual_master_node_id;