Parallel query fails on standby server
От | Ashutosh Sharma |
---|---|
Тема | Parallel query fails on standby server |
Дата | |
Msg-id | CAE9k0P=TMHmd74zpErUue_ZfFqnuMdR7de_45+eazeq=kcKiZQ@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Parallel query fails on standby server
|
Список | pgsql-hackers |
Hi All,
While testing a parallel scan feature on standby server, it is found that the parallel query fails with an error "ERROR: failed to initialize transaction_read_only to 0".
Following are the steps used to reproduce the issue:
Master :-
edb=# create table ert(n int);
edb=# insert into ert values (generate_series(1,5000000));
edb=# analyze ert;
edb=# vacuum ert;
Slave :-
edb=# set max_parallel_degree =5;
SET
edb=# explain analyze verbose select * from ert where n<=1000;
ERROR: failed to initialize transaction_read_only to 0
CONTEXT: parallel worker, PID 26042
Root cause Analysis: After debugging the worker, it is observed that in RestoreGUCState(), if a guc var can't be skipped it is Initialiazed with a default value and
in this process when a guc variable "transaction_read_only" is being Initialzed it calls a check_hook check_transaction_read_only() which eventually fails due to
below check which says the guc var "transaction_read_only" can't be set while recovery is in progress:
if (RecoveryInProgress())
{
GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
GUC_check_errmsg("cannot set transaction read-write mode during recovery");
return false;
}
Solution: Make use of a global variable "InitializingParallelWorker" to protect the check for RecoveryInProgress() when Parallel Worker is being Initialsed.
PFA patch to fix the issue.
With Regards,While testing a parallel scan feature on standby server, it is found that the parallel query fails with an error "ERROR: failed to initialize transaction_read_only to 0".
Following are the steps used to reproduce the issue:
Master :-
edb=# create table ert(n int);
edb=# insert into ert values (generate_series(1,5000000));
edb=# analyze ert;
edb=# vacuum ert;
Slave :-
edb=# set max_parallel_degree =5;
SET
edb=# explain analyze verbose select * from ert where n<=1000;
ERROR: failed to initialize transaction_read_only to 0
CONTEXT: parallel worker, PID 26042
Root cause Analysis: After debugging the worker, it is observed that in RestoreGUCState(), if a guc var can't be skipped it is Initialiazed with a default value and
in this process when a guc variable "transaction_read_only" is being Initialzed it calls a check_hook check_transaction_read_only() which eventually fails due to
below check which says the guc var "transaction_read_only" can't be set while recovery is in progress:
if (RecoveryInProgress())
{
GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
GUC_check_errmsg("cannot set transaction read-write mode during recovery");
return false;
}
Solution: Make use of a global variable "InitializingParallelWorker" to protect the check for RecoveryInProgress() when Parallel Worker is being Initialsed.
PFA patch to fix the issue.
Вложения
В списке pgsql-hackers по дате отправления: