Skip to content

Commit 212e8dc

Browse files
committed
Fix FileSeek for snapshots
1 parent 64b55ea commit 212e8dc

File tree

1 file changed

+10
-5
lines changed
  • src/backend/storage/file

1 file changed

+10
-5
lines changed

src/backend/storage/file/fd.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,7 @@ FileRead(File file, char *buffer, int amount, uint32 wait_event_info)
20512051
elog(ERROR, "[SFS] Could not seek file: %m");
20522052

20532053
if (sfs_read_file(vfdP->snap_fd, buffer, amount) != amount)
2054-
elog(ERROR, "[SFS] Field to read snapshot file: %m");
2054+
elog(ERROR, "[SFS] Failed to read snapshot file: %m");
20552055

20562056
pgstat_report_wait_end();
20572057
if (sfs_basebackup)
@@ -2389,11 +2389,16 @@ FileSeek(File file, off_t offset, int whence)
23892389
if (!OpenSnapshotFiles(vfdP, snap_id, false))
23902390
continue;
23912391

2392-
for (i = 0; i < RELSEG_SIZE; i++)
2392+
for (i = RELSEG_SIZE; --i != 0;)
23932393
{
2394-
sfs_segment_offs_t offs = vfdP->snap_map->offs[i];
2395-
if (offs >= vfdP->seekPos)
2396-
vfdP->seekPos = offs + BLCKSZ - 1;
2394+
if (vfdP->snap_map->offs[i] != 0)
2395+
{
2396+
if (i*BLCKSZ >= vfdP->seekPos)
2397+
{
2398+
vfdP->seekPos = i*BLCKSZ;
2399+
}
2400+
break;
2401+
}
23972402
}
23982403
}
23992404
}

0 commit comments

Comments
 (0)