mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Don't call the function that may raise an error while holding spinlock.
It's not safe to raise an error while holding spinlock. But previously logical replication worker for table sync called the function which reads the system catalog and may raise an error while it's holding spinlock. Which could lead to the trouble where spinlock will never be released and the server gets stuck infinitely. Author: Petr Jelinek Reviewed-by: Kyotaro Horiguchi and Fujii Masao Reported-by: Fujii Masao Discussion: http://postgr.es/m/CAHGQGwFDWh_Qr-q_GEMpD+qH=vYPMdVqw=ZOSY3kX_Pna9R9SA@mail.gmail.com
This commit is contained in:
@ -705,18 +705,21 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
|
|||||||
{
|
{
|
||||||
char *slotname;
|
char *slotname;
|
||||||
char *err;
|
char *err;
|
||||||
|
char relstate;
|
||||||
|
XLogRecPtr relstate_lsn;
|
||||||
|
|
||||||
/* Check the state of the table synchronization. */
|
/* Check the state of the table synchronization. */
|
||||||
StartTransactionCommand();
|
StartTransactionCommand();
|
||||||
SpinLockAcquire(&MyLogicalRepWorker->relmutex);
|
relstate = GetSubscriptionRelState(MyLogicalRepWorker->subid,
|
||||||
MyLogicalRepWorker->relstate =
|
MyLogicalRepWorker->relid,
|
||||||
GetSubscriptionRelState(MyLogicalRepWorker->subid,
|
&relstate_lsn, false);
|
||||||
MyLogicalRepWorker->relid,
|
|
||||||
&MyLogicalRepWorker->relstate_lsn,
|
|
||||||
false);
|
|
||||||
SpinLockRelease(&MyLogicalRepWorker->relmutex);
|
|
||||||
CommitTransactionCommand();
|
CommitTransactionCommand();
|
||||||
|
|
||||||
|
SpinLockAcquire(&MyLogicalRepWorker->relmutex);
|
||||||
|
MyLogicalRepWorker->relstate = relstate;
|
||||||
|
MyLogicalRepWorker->relstate_lsn = relstate_lsn;
|
||||||
|
SpinLockRelease(&MyLogicalRepWorker->relmutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To build a slot name for the sync work, we are limited to NAMEDATALEN -
|
* To build a slot name for the sync work, we are limited to NAMEDATALEN -
|
||||||
* 1 characters. We cut the original slot name to NAMEDATALEN - 28 chars
|
* 1 characters. We cut the original slot name to NAMEDATALEN - 28 chars
|
||||||
|
Reference in New Issue
Block a user