[pgpool-hackers: 3783] Re: 073.pg_terminate_backend sometimes fails

Tatsuo Ishii ishii at sraoss.co.jp
Mon Aug 17 17:26:36 JST 2020


>> Hi Ishii-San
>> 
>> I have tried like a dozen times but never got the failure even once.
>> 
>> Looking at the log snippet you shared  it appears that this failure
>> is a random timing-based and it is not really a problem with the
>> handling of pg_terminate_backend but somehow it is related to
>> missing connection_count_down() call.
>> 
>> I suppose connection_count_down() is not called in one of the code
>> path that gets executed when we get this "write on backend failed"
>> warning
>> i.e.
>> .WARNING:  write on backend 0 failed with error :"Success"
>> DETAIL:  while trying to write data from offset: 0 wlen: 5
>> 
>> The reason I suspect that is, I never saw this above warning message in
>> pg_terminate_backend test case logs, but it is present in the log snippet
>> you shared above so I suspect if the backend gets terminated when
>> pgpool process is about to write to the backend socket then in that code
>> patch somehow we don't execute the connection_count_down() function
>> that leads to this regression test failure.
> 
> I agree that the error is caused by timing but probably the reasoning
> is different. I think what is happing is:
> 
> 1. $PSQL test -p $PGPORT -c "SELECT pg_sleep(10);" &
>    connection_count_up is called
> 
> (sleep 2)
> 
> 2. $PSQL test -p $PGPORT -c "SELECT pg_terminate_backend($PID)"
>    connection_count_up is called
>    connection_count_down is called
> 
> 3. Check count_up and count_down.
> 
> If the machine is slow, 10 seconds has passed since 1 (thus
> connection_count_down is called) and test succeeds. Probably my
> machine is too fast to execute 3 before 10 seconds passed since 1, and
> the test failed.
> 
> I inserted "sleep 5" between 2 and 3, and now the test succeeds. Patch
> attached. What do you think?

I have pushed this to master and 4.1 branch (4.0 does not seem to have
the connection count validation). Let's see if the build farm stops to
complain.

Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp


More information about the pgpool-hackers mailing list