Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitba4cc05

Browse files
committed
Drop slot's LWLock before returning from SaveSlotToPath()
When SaveSlotToPath() is called with elevel=LOG, the early exits didn'trelease the slot's io_in_progress_lock.This could result in a walsender being stuck on the lock forever. Apossible way to get into this situation is if the offending code pathsare triggered in a low disk space situation.Author: Pavan Deolasee <pavan.deolasee@2ndquadrant.com>Reported-by: Craig Ringer <craig@2ndquadrant.com>Discussion:https://www.postgresql.org/message-id/flat/56a138c5-de61-f553-7e8f-6789296de785%402ndquadrant.com
1 parent58995db commitba4cc05

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎src/backend/replication/slot.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,12 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel)
12571257
fd=OpenTransientFile(tmppath,O_CREAT |O_EXCL |O_WRONLY |PG_BINARY);
12581258
if (fd<0)
12591259
{
1260+
/*
1261+
* If not an ERROR, then release the lock before returning. In case
1262+
* of an ERROR, the error recovery path automatically releases the
1263+
* lock, but no harm in explicitly releasing even in that case.
1264+
*/
1265+
LWLockRelease(&slot->io_in_progress_lock);
12601266
ereport(elevel,
12611267
(errcode_for_file_access(),
12621268
errmsg("could not create file \"%s\": %m",
@@ -1288,6 +1294,7 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel)
12881294

12891295
pgstat_report_wait_end();
12901296
CloseTransientFile(fd);
1297+
LWLockRelease(&slot->io_in_progress_lock);
12911298

12921299
/* if write didn't set errno, assume problem is no disk space */
12931300
errno=save_errno ?save_errno :ENOSPC;
@@ -1307,6 +1314,7 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel)
13071314

13081315
pgstat_report_wait_end();
13091316
CloseTransientFile(fd);
1317+
LWLockRelease(&slot->io_in_progress_lock);
13101318
errno=save_errno;
13111319
ereport(elevel,
13121320
(errcode_for_file_access(),
@@ -1321,6 +1329,7 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel)
13211329
/* rename to permanent file, fsync file and directory */
13221330
if (rename(tmppath,path)!=0)
13231331
{
1332+
LWLockRelease(&slot->io_in_progress_lock);
13241333
ereport(elevel,
13251334
(errcode_for_file_access(),
13261335
errmsg("could not rename file \"%s\" to \"%s\": %m",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp