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:45 +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 0083dac740cf866a7f7f44f792c12166b58e98a7..3277371ba247683b3571724de7c44442b110a397 100644 (file)
@@ -298,12 +298,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.
         */
@@ -318,6 +312,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;