Skip to content

Commit 851b3b7

Browse files
author
Commitfest Bot
committed
[CF 5454] v2 - Bug: mdunlinkfiletag unlinks mainfork seg.0 instead of indicated fork+segment
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5454 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CAEze2WjfP95SL_Hsu7GzYXLnQyEsT49zOnNvbY_mBLCFiQra1g@mail.gmail.com Author(s): Matthias van de Meent
2 parents daa1689 + 927bb88 commit 851b3b7

File tree

1 file changed

+10
-7
lines changed
  • src/backend/storage/smgr

1 file changed

+10
-7
lines changed

src/backend/storage/smgr/md.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ static void mdunlinkfork(RelFileLocatorBackend rlocator, ForkNumber forknum,
137137
static MdfdVec *mdopenfork(SMgrRelation reln, ForkNumber forknum, int behavior);
138138
static void register_dirty_segment(SMgrRelation reln, ForkNumber forknum,
139139
MdfdVec *seg);
140-
static void register_unlink_segment(RelFileLocatorBackend rlocator, ForkNumber forknum,
141-
BlockNumber segno);
140+
static void register_unlink_tombstone(RelFileLocatorBackend rlocator);
142141
static void register_forget_request(RelFileLocatorBackend rlocator, ForkNumber forknum,
143142
BlockNumber segno);
144143
static void _fdvec_resize(SMgrRelation reln,
@@ -410,7 +409,7 @@ mdunlinkfork(RelFileLocatorBackend rlocator, ForkNumber forknum, bool isRedo)
410409

411410
/* Register request to unlink first segment later */
412411
save_errno = errno;
413-
register_unlink_segment(rlocator, forknum, 0 /* first seg */ );
412+
register_unlink_tombstone(rlocator);
414413
errno = save_errno;
415414
}
416415

@@ -1532,15 +1531,16 @@ register_dirty_segment(SMgrRelation reln, ForkNumber forknum, MdfdVec *seg)
15321531
}
15331532

15341533
/*
1535-
* register_unlink_segment() -- Schedule a file to be deleted after next checkpoint
1534+
* register_unlink_tombstone()
1535+
*
1536+
* Schedule a file to be deleted after next checkpoint
15361537
*/
15371538
static void
1538-
register_unlink_segment(RelFileLocatorBackend rlocator, ForkNumber forknum,
1539-
BlockNumber segno)
1539+
register_unlink_tombstone(RelFileLocatorBackend rlocator)
15401540
{
15411541
FileTag tag;
15421542

1543-
INIT_MD_FILETAG(tag, rlocator.locator, forknum, segno);
1543+
INIT_MD_FILETAG(tag, rlocator.locator, MAIN_FORKNUM, 0);
15441544

15451545
/* Should never be used with temp relations */
15461546
Assert(!RelFileLocatorBackendIsTemp(rlocator));
@@ -1933,6 +1933,9 @@ mdunlinkfiletag(const FileTag *ftag, char *path)
19331933
{
19341934
RelPathStr p;
19351935

1936+
/* We only unlink tombstone files through this mechanism */
1937+
Assert(ftag->forknum == MAIN_FORKNUM && ftag->segno == 0);
1938+
19361939
/* Compute the path. */
19371940
p = relpathperm(ftag->rlocator, MAIN_FORKNUM);
19381941
strlcpy(path, p.str, MAXPGPATH);

0 commit comments

Comments
 (0)