[HACKERS] Passing query string to workers

Поиск
Список
Период
Сортировка
От Rafia Sabih
Тема [HACKERS] Passing query string to workers
Дата
Msg-id CAOGQiiMH_nOOGkxhbidnwfZ1n5pQayEzbE5iv9rO2oA8GfVj0Q@mail.gmail.com
обсуждение исходный текст
Ответы Re: [HACKERS] Passing query string to workers  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hello everybody,

Currently, query string is not passed to the workers and only master has it. In the events, when multiple queries are running on a server and for one query some worker crashes then it becomes quite burdensome to find the query with the crashed worker, since on the worker crash no query is displayed.

To fix this, I propose a patch wherein query string is passed to the workers as well, hence, displayed when worker crashes.

Approach:
A token for query string is created in the shared memory, this token is populated with the query string using the global string -- debug_query_string. Now, for each of the worker when ExecGetParallelQueryDesc is called, we retrieve the query text from shared memory and pass it to CreateQueryDesc.

Next, to ensure that query gets displayed at the time of crash, BackendStatusArray needs to be populated correctly, specifically for our purpose, activity needs to be filled with current query. For this I called pgstat_report_activity in ParallelWorkerMain, with the query string, this populates workers' tuples in system table -- pgstat_activity as well. Previously, pgstat_report_activity was only called for master in exec_simple_query, hence, for workers pgstat_activity remained null.

Results:
Here is an output for artificially created worker crash with and without the patch.

Without the patch error report on worker crash:
 LOG:  worker process: parallel worker for PID 49739 (PID 49741) was terminated by signal 11: Segmentation fault

Error report with the patch:
 LOG:  worker process: parallel worker for PID 51757 (PID 51758) was terminated by signal 11: Segmentation fault
2017-01-11 11:10:27.630 IST [51742] DETAIL:  Failed process was running: explain analyse select
l_returnflag,
l_linestatus,
sum(l_quantity) as sum_qty,
sum(l_extendedprice) as sum_base_price,
sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
avg(l_quantity) as avg_qty,
avg(l_extendedprice) as avg_price,
avg(l_discount) as avg_disc,
count(*) as count_order
from
lineitem
where
l_shipdate <= date '1998-12-01' - interval '119' day
group by
l_returnflag,
l_linestatus
order by
l_returnflag,
l_linestatus
LIMIT 1;

Inputs of all sorts are encouraged.
--
Regards,
Rafia Sabih
EnterpriseDB: http://www.enterprisedb.com/
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Kyotaro HORIGUCHI
Дата:
Сообщение: Re: [HACKERS] Floating point comparison inconsistencies of thegeometric types
Следующее
От: Ashutosh Bapat
Дата:
Сообщение: Re: [HACKERS] pg_restore accepts -j -1