View Issue Details

IDProjectCategoryView StatusLast Update
0000269Pgpool-IIBugpublic2017-05-18 17:48
ReporternagataAssigned Tonagata 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionopen 
Product Version3.5.5 
Target VersionFixed in Version3.5.6 
Summary0000269: authentication timeout with connection_life_time
DescriptionWhen connection_life_time is enabled, "authentication timeout" can
occur right after a client connects to Pgpool-II.

SIGALRM signal is used for both connection_life_time and authentication_timeout. Usually, SIGALRM is for connection_life_time, but when the new connection is arrive, read_startup_packet() is called, and the handler for authentication_timeout is set bu pool_signal() and alarm(authentication_timeout) is called in enable_authentication_timeout(). However, if connection_life_time is expired *between pool_signal() and alarm()*, authenticate_timeout() will be called when connection_life_time is expired instead of pool_backend_timer_handler().

The attached simple patch will fix the bug, but there may be better way to handle SIGALRM more carefully.
Steps To ReproduceTo reproduce this, apply the following patch;

 --- a/src/protocol/child.c
 +++ b/src/protocol/child.c
 @@ -1026,6 +1026,7 @@ static void enable_authentication_timeout(void)
         if(pool_config->authentication_timeout <= 0)
                 return;
         pool_signal(SIGALRM, authentication_timeout);
 + sleep(3); /* connection_life_time could be expired here */
         alarm(pool_config->authentication_timeout);
        alarm_enabled = true;
  }

configure pgpool.conf as below;

 num_init_children = 1
 max_pool = 1
 connection_life_time = 1

and connect to pgpool-II repeatedly.

 
$ psql test -c "select 1" > /dev/null
$ psql test -c "select 1" > /dev/null
...
$ psql test -c "select 1" > /dev/null

psql: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.

TagsNo tags attached.

Activities

nagata

2016-12-14 12:04

developer  

authencitation_timeout.patch (443 bytes)
diff --git a/src/protocol/child.c b/src/protocol/child.c
index 323d858..99782ef 100644
--- a/src/protocol/child.c
+++ b/src/protocol/child.c
@@ -1025,8 +1025,8 @@ static void enable_authentication_timeout(void)
 {
 	if(pool_config->authentication_timeout <= 0)
 		return;
-	pool_signal(SIGALRM, authentication_timeout);
 	alarm(pool_config->authentication_timeout);
+	pool_signal(SIGALRM, authentication_timeout);
 	alarm_enabled = true;
 }
 

Issue History

Date Modified Username Field Change
2016-12-14 12:04 nagata New Issue
2016-12-14 12:04 nagata File Added: authencitation_timeout.patch
2016-12-14 12:09 nagata Description Updated View Revisions
2016-12-14 12:10 nagata Steps to Reproduce Updated View Revisions
2016-12-20 09:31 t-ishii Assigned To => nagata
2016-12-20 09:31 t-ishii Status new => assigned
2017-05-18 17:48 t-ishii Status assigned => resolved
2017-05-18 17:48 t-ishii Fixed in Version => 3.5.6