pgpool / pgpool2

This is the official mirror of git://git.postgresql.org/git/pgpool2.git. Note that this is just a *mirror* - we don't work with pull requests on github. Please subscribe to pgpool-hackers mailing list from our website and submit your patch to this mailing list.
https://www.pgpool.net
Other
305 stars 87 forks source link

Child process was terminated after receiving `SYNC` message #26

Open Zatvobor opened 5 years ago

Zatvobor commented 5 years ago

we've been using 4.0.2 (4.0.3 has the same behavior) with enabled memcached based query cache. So, after statement: Execute, closing and finally syncing messages the current connection is crashed with message pid 1: WARNING: child process with pid: 53 was terminated by segmentation fault.

So, here is how to reproduce the issue (based on https://github.com/epgsql/epgsql client):

➜  epgsql git:(master) make compile && ./rebar3 shell
===> Verifying dependencies...
===> Compiling epgsql
Erlang/OTP 21 [erts-10.3.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]

Eshell V10.3.1  (abort with ^G)
1> {ok, C} = epgsql:connect("localhost", "postgres", "postgres", #{database =>"localhost"}).
{ok,<0.127.0>}
# 2019-04-02 12:02:45: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: SELECT count(*) FROM pg_catalog.pg_class AS c, pg_attribute AS a WHERE c.relname = 'pg_class' AND a.attrelid = c.oid AND a.attname = 'relistemp'
# 2019-04-02 12:02:45: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: SELECT count(*) FROM pg_catalog.pg_class AS c, pg_namespace AS n WHERE c.relname = 'pg_type' AND c.relnamespace = n.oid AND n.nspname ~ '^pg_temp_'
# 2019-04-02 12:02:45: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: SELECT count(*) from (SELECT has_function_privilege('postgres', 'pg_catalog.to_regclass(cstring)', 'execute') WHERE EXISTS(SELECT * FROM pg_catalog.pg_proc AS p WHERE p.proname = 'to_regclass')) AS s
# 2019-04-02 12:02:45: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: SELECT count(*) FROM pg_catalog.pg_class AS c WHERE c.relname = 'pg_namespace'
# 2019-04-02 12:02:45: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: SELECT count(*) FROM pg_class AS c, pg_namespace AS n WHERE c.oid = pg_catalog.to_regclass('"pg_type"') AND c.relnamespace = n.oid AND n.nspname = 'pg_catalog'
# 2019-04-02 12:02:45: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: SELECT typname::text, oid::int4, typarray::int4 FROM pg_type WHERE typname IN ('geometry','hstore') ORDER BY typname
2> epgsql:parse(C, "statement", "SELECT $1", [int2]).
{ok,{statement,"statement",
               [{column,<<"?column?">>,int2,21,2,-1,1}],
               [int2],
               [{21,int2,false}]}}
# 2019-04-02 12:03:02: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: Parse: SELECT $1
# 2019-04-02 12:03:02: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: D message
3> epgsql:prepared_query(C, "statement", [1]).
{ok,[{column,<<"?column?">>,int2,21,2,-1,1}],[{1}]}
# 2019-04-02 12:04:32: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: D message
# 2019-04-02 12:04:32: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: B message
# 2019-04-02 12:04:32: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: Execute: SELECT $1
# 2019-04-02 12:04:32: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: SELECT oid FROM pg_database WHERE datname = 'localhost'
4> epgsql:prepared_query(C, "statement", [1]).
{ok,[{column,<<"?column?">>,int2,21,2,-1,1}],[{1}]}
# 2019-04-02 12:04:33: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: D message
# 2019-04-02 12:04:33: pid 53: LOG:  DB node id: 0 backend pid: 23046 statement: B message
# 2019-04-02 12:04:33: pid 53: LOG:  fetch from memory cache
# 2019-04-02 12:04:33: pid 53: DETAIL:  query result fetched from cache. statement: SELECT $1 00010001000100000002000100010001
6> epgsql:close(C, statement, "statement").
ok
# 2019-04-02 12:12:58: pid 53: LOG:  DB node id: 0 backend pid: 23122 statement: C message
7> epgsql:sync(C).
ok
# 2019-04-02 12:13:38: pid 1: WARNING:  child process with pid: 53 was terminated by segmentation fault
# 2019-04-02 12:13:38: pid 1: LOG:  fork a new child process with pid: 59

After turning off memory_cache_enabled OR with out final SYNC message the issue is not present - the appliance/cached query flow behaves as expected. Thanks.

pengbo0328 commented 5 years ago

Thank you for reporting this issue.

For reporting bug, we are using "Bug tracking system"? https://www.pgpool.net/mantisbt/my_view_page.php

Could you report this issue in "Bug tracking system" again?

See how to report issues: https://pgpool.net/mediawiki/index.php/Bug_tracking_system

Zatvobor commented 5 years ago

Here is a link to the issue report: