Typos in smgr.c

Started by Sergey Shinderuk4 months ago4 messageshackers
Jump to latest
#1Sergey Shinderuk
s.shinderuk@postgrespro.ru

Hello,

while reading the code I spotted a couple of typos in smgr.c. Please see attached.

Looks like PgAioTargetData.smgr.skip_fsync is not used anywhere.

Best regards,
Sergey Shinderuk
https://postgrespro.com/

Attachments:

t253231_1
typos-in-smgr.diffapplication/octet-stream; name=typos-in-smgr.diff; x-unix-mode=0644Download+2-2
#2Chao Li
li.evan.chao@gmail.com
In reply to: Sergey Shinderuk (#1)
Re: Typos in smgr.c

On Jul 29, 2026, at 15:21, Сергей Шиндерук <s.shinderuk@postgrespro.ru> wrote:

Hello,

while reading the code I spotted a couple of typos in smgr.c. Please see attached.

Looks like PgAioTargetData.smgr.skip_fsync is not used anywhere.

Best regards,
Sergey Shinderuk
https://postgrespro.com/

<typos-in-smgr.diff>

1.
```
- * If more than one block is intended to be read, callers need to use
+ * If more than one block is intended to be written, callers need to use
```

Yep, this seems like a copy-pasto.

2.
```
@@ -1053,7 +1053,7 @@ pgaio_io_set_target_smgr(PgAioHandle *ioh,
sd->smgr.nblocks = nblocks;
sd->smgr.is_temp = SmgrIsTemp(smgr);
/* Temp relations should never be fsync'd */
- sd->smgr.skip_fsync = skip_fsync && !SmgrIsTemp(smgr);
+ sd->smgr.skip_fsync = skip_fsync || SmgrIsTemp(smgr);
```

This is actually a bug fix. The current code incorrectly sets skip_fsync to false for every temporary relation, but temporary relations should not be fsynced.

Maybe worth adding a test under src/test/modules/test_aio.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

#3Yuefei Shi
shiyuefei1004@gmail.com
In reply to: Chao Li (#2)
Re: Typos in smgr.c

Hi,

I think this fix is reasonable. The current assignment:

sd->smgr.skip_fsync = skip_fsync && !SmgrIsTemp(smgr);

does not match the comment that temporary relations should never be
fsync'd, nor the existing smgr write path logic. The condition should be:

sd->smgr.skip_fsync = skip_fsync || SmgrIsTemp(smgr);

Although skip_fsync is not currently consumed, this fixes the semantics and
avoids carrying an incorrect condition into future AIO write support.

Thanks.

#4Heikki Linnakangas
hlinnaka@iki.fi
In reply to: Chao Li (#2)
Re: Typos in smgr.c

On 29/07/2026 10:37, Chao Li wrote:

On Jul 29, 2026, at 15:21, Сергей Шиндерук <s.shinderuk@postgrespro.ru> wrote:

Hello,

while reading the code I spotted a couple of typos in smgr.c. Please see attached.

Looks like PgAioTargetData.smgr.skip_fsync is not used anywhere.

Best regards,
Sergey Shinderuk
https://postgrespro.com/

<typos-in-smgr.diff>

1.
```
- * If more than one block is intended to be read, callers need to use
+ * If more than one block is intended to be written, callers need to use
```

Yep, this seems like a copy-pasto.

2.
```
@@ -1053,7 +1053,7 @@ pgaio_io_set_target_smgr(PgAioHandle *ioh,
sd->smgr.nblocks = nblocks;
sd->smgr.is_temp = SmgrIsTemp(smgr);
/* Temp relations should never be fsync'd */
- sd->smgr.skip_fsync = skip_fsync && !SmgrIsTemp(smgr);
+ sd->smgr.skip_fsync = skip_fsync || SmgrIsTemp(smgr);
```

This is actually a bug fix. The current code incorrectly sets skip_fsync to false for every temporary relation, but temporary relations should not be fsynced.

Yep, committed.

Maybe worth adding a test under src/test/modules/test_aio.

It's a bit hard to come up with a sensible test because "skip_fsync" is
currently unused.

- Heikki