Skip to content

Commit

Permalink
Do not produce open file error for unlogged relations (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
knizhnik authored and tristan957 committed Feb 6, 2024
1 parent ebf2fec commit 0d5c7be
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/backend/storage/smgr/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,13 @@ mdnblocks(SMgrRelation reln, ForkNumber forknum)
BlockNumber nblocks;
BlockNumber segno;

mdopenfork(reln, forknum, EXTENSION_FAIL);
/* NEON: md smgr is used in Neon for unlogged and temp relations.
* After compute node restart their data is deleted but unlogged tables are still present in system catalog.
* This is a difference with Vanilla Postgres where unlogged relations are truncated only after abnormal termination.
* To avoid "could not open file" we have to use EXTENSION_RETURN_NULL hear instead of EXTENSION_FAIL
*/
if (!mdopenfork(reln, forknum, RelFileNodeBackendIsTemp(reln->smgr_rnode) ? EXTENSION_FAIL : EXTENSION_RETURN_NULL))
return 0;

/* mdopen has opened the first segment */
Assert(reln->md_num_open_segs[forknum] > 0);
Expand Down

0 comments on commit 0d5c7be

Please sign in to comment.