Fix bug in release_connection() introduced by d9f45c9018
authorTomas Vondra <[email protected]>
Tue, 7 Nov 2017 17:34:55 +0000 (18:34 +0100)
committerTomas Vondra <[email protected]>
Tue, 7 Nov 2017 17:34:55 +0000 (18:34 +0100)
d9f45c9018ec3ec1fc11e4be2be7f9728a1799b1 attempted to refactor
release_connection() to make it more readable, but unfortunately
inverted the force_destroy check, causing regression failures.

In hindsight, the refactoring was rather arbitrary and not really
helping with the readability, so just revert to the original code
(but keep the comments, explaining what's happening).

src/backend/pgxc/pool/poolmgr.c

index 768ed80d7e7715fa4c5f7a8112eb0a69fb9328da..6aa2922813c1b38269381425d9fc2fee69b9dfb5 100644 (file)
@@ -2935,33 +2935,30 @@ release_connection(DatabasePool *dbPool, PGXCNodePoolSlot *slot,
                return;
        }
 
-       /*
-        * The node pool exists, but we've been asked to forcefully close
-        * the connection, so do as asked.
-        */
+       /* return or discard */
        if (!force_destroy)
        {
-               elog(DEBUG1, "Cleaning up connection from pool %s (node %d), closing",
-                       nodePool->connstr, node);
-
+               /*
+                * Everything peachy, so just insert the connection (slot) into the
+                * array and increase the number of free connections in the pool.
+                * Also note the timestamp when the connection was released.
+                */
+               nodePool->slot[(nodePool->freeSize)++] = slot;
+               slot->released = time(NULL);
+       }
+       else
+       {
+               /*
+                * The node pool exists, but we've been asked to forcefully close
+                * the connection, so do as asked.
+                */
+               elog(DEBUG1, "Cleaning up connection from pool %s, closing", nodePool->connstr);
                destroy_slot(slot);
-
                /* Decrement pool size */
                (nodePool->size)--;
-
                /* Ensure we are not below minimum size */
                grow_pool(dbPool, node);
-
-               return;
        }
-
-       /*
-        * Everything peachy, so just insert the connection (slot) into the
-        * array and increase the number of free connections in the pool.
-        * Also note the timestamp when the connection was released.
-        */
-       nodePool->slot[(nodePool->freeSize)++] = slot;
-       slot->released = time(NULL);
 }