pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Typos in smgr.c
4+ messages / 4 participants
[nested] [flat]

Commits from this thread:
  2026-11-19 61f6021b11 67ad2443f7 75829f0439  Fix setting skip_fsync on temp tables
* Typos in smgr.c
@ 2026-07-29 07:21 Сергей Шиндерук <s.shinderuk@postgrespro.ru>
  2026-07-29 07:37 ` Re: Typos in smgr.c Chao Li <li.evan.chao@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Сергей Шиндерук @ 2026-07-29 07:21 UTC (permalink / raw)
  To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

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:

typos-in-smgr.diff (application/octet-stream, 881B) download diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c index 5391640d861..0b522a49564 100644 --- a/src/backend/storage/smgr/smgr.c +++ b/src/backend/storage/smgr/smgr.c @@ -784,7 +784,7 @@ smgrstartreadv(PgAioHandle *ioh, * fsync the relation, so we needn't bother. Temporary relations also * do not require fsync. * - * 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 * smgrmaxcombine() to check how many blocks can be combined into one IO. */ void @@ -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); } /*
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: Typos in smgr.c
  2026-07-29 07:21 Typos in smgr.c Сергей Шиндерук <s.shinderuk@postgrespro.ru>
@ 2026-07-29 07:37 ` Chao Li <li.evan.chao@gmail.com>
  2026-07-29 08:05   ` Re: Typos in smgr.c Yuefei Shi <shiyuefei1004@gmail.com>
  2026-11-19 12:52   ` Re: Typos in smgr.c Heikki Linnakangas <hlinnaka@iki.fi>
  0 siblings, 2 replies; 4+ messages in thread

From: Chao Li @ 2026-07-29 07:37 UTC (permalink / raw)
  To: Сергей Шиндерук <s.shinderuk@postgrespro.ru>; +Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>



> 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/









^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Typos in smgr.c
  2026-07-29 07:21 Typos in smgr.c Сергей Шиндерук <s.shinderuk@postgrespro.ru>
  2026-07-29 07:37 ` Re: Typos in smgr.c Chao Li <li.evan.chao@gmail.com>
@ 2026-07-29 08:05   ` Yuefei Shi <shiyuefei1004@gmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Yuefei Shi @ 2026-07-29 08:05 UTC (permalink / raw)
  To: Chao Li <li.evan.chao@gmail.com>; +Cc: Сергей Шиндерук <s.shinderuk@postgrespro.ru>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

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.

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Typos in smgr.c
  2026-07-29 07:21 Typos in smgr.c Сергей Шиндерук <s.shinderuk@postgrespro.ru>
  2026-07-29 07:37 ` Re: Typos in smgr.c Chao Li <li.evan.chao@gmail.com>
@ 2026-11-19 12:52   ` Heikki Linnakangas <hlinnaka@iki.fi>
  1 sibling, 0 replies; 4+ messages in thread

From: Heikki Linnakangas @ 2026-11-19 12:52 UTC (permalink / raw)
  To: Chao Li <li.evan.chao@gmail.com>; Сергей Шиндерук <s.shinderuk@postgrespro.ru>; +Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

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







^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2026-11-19 12:52 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-29 07:21 Typos in smgr.c Сергей Шиндерук <s.shinderuk@postgrespro.ru>
2026-07-29 07:37 ` Chao Li <li.evan.chao@gmail.com>
2026-07-29 08:05   ` Yuefei Shi <shiyuefei1004@gmail.com>
2026-11-19 12:52   ` Heikki Linnakangas <hlinnaka@iki.fi>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox