Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ef23956

Browse files
committed
Maintain number of dedicated backends for session pool
1 parent 80426b3 commit ef23956

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/backend/postmaster/proxy.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ typedef struct SessionPool
113113
Channel* pending_clients; /* List of clients waiting for free backend */
114114
Proxy* proxy; /* Owner of this pool */
115115
int n_launched_backends; /* Total number of launched backends */
116+
int n_dedicated_backends;/* Number of dedicated (tainted) backends */
116117
int n_idle_backends; /* Number of backends in idle state */
117118
int n_connected_clients; /* Total number of connected clients */
118119
int n_idle_clients; /* Number of clients in idle state */
@@ -208,6 +209,7 @@ backend_reschedule(Channel* chan, bool is_new)
208209
ELOG(LOG, "Backed %d is tainted", chan->backend_pid);
209210
chan->backend_is_tainted = true;
210211
chan->proxy->state->n_dedicated_backends += 1;
212+
chan->pool->n_dedicated_backends += 1;
211213
}
212214
return true;
213215
}
@@ -357,7 +359,7 @@ client_connect(Channel* chan, int startup_packet_size)
357359
* Use then for launching pooler worker backends and report error
358360
* if GUCs in startup packets are different.
359361
*/
360-
if (chan->pool->n_launched_backends == 0)
362+
if (chan->pool->n_launched_backends == chan->pool->n_dedicated_backends)
361363
{
362364
list_free(chan->pool->startup_gucs);
363365
if (chan->pool->cmdline_options)
@@ -372,7 +374,7 @@ client_connect(Channel* chan, int startup_packet_size)
372374
if (!string_list_equal(chan->pool->startup_gucs, chan->client_port->guc_options) ||
373375
!string_equal(chan->pool->cmdline_options, chan->client_port->cmdline_options))
374376
{
375-
elog(LOG, "Ignoring GUCs of client %s",
377+
elog(LOG, "Ignoring startup GUCs of client %s",
376378
NULLSTR(chan->client_port->application_name));
377379
}
378380
}
@@ -1087,6 +1089,7 @@ channel_remove(Channel* chan)
10871089
{
10881090
chan->proxy->state->n_backends -= 1;
10891091
chan->proxy->state->n_dedicated_backends -= chan->backend_is_tainted;
1092+
chan->pool->n_dedicated_backends -= chan->backend_is_tainted;
10901093
chan->pool->n_launched_backends -= 1;
10911094
closesocket(chan->backend_socket);
10921095
pfree(chan->handshake_response);

0 commit comments

Comments
 (0)