Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf321ec2

Browse files
committed
aio: Pass result of local callbacks to ->report_return
Otherwise the results of e.g. temp table buffer verification errors will notreach bufmgr.c. Obviously that's not right. Found while expanding the testsfor invalid buffer contents.Reviewed-by: Noah Misch <noah@leadboat.com>Discussion:https://postgr.es/m/20250326001915.bc.nmisch@google.com
1 parent96da905 commitf321ec2

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

‎src/backend/storage/aio/aio.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,21 @@ pgaio_io_reclaim(PgAioHandle *ioh)
626626

627627
/*
628628
* It's a bit ugly, but right now the easiest place to put the execution
629-
* ofshared completion callbacks is this function, as we need to execute
629+
* oflocal completion callbacks is this function, as we need to execute
630630
* local callbacks just before reclaiming at multiple callsites.
631631
*/
632632
if (ioh->state==PGAIO_HS_COMPLETED_SHARED)
633633
{
634-
pgaio_io_call_complete_local(ioh);
634+
PgAioResultlocal_result;
635+
636+
local_result=pgaio_io_call_complete_local(ioh);
635637
pgaio_io_update_state(ioh,PGAIO_HS_COMPLETED_LOCAL);
638+
639+
if (ioh->report_return)
640+
{
641+
ioh->report_return->result=local_result;
642+
ioh->report_return->target_data=ioh->target_data;
643+
}
636644
}
637645

638646
pgaio_debug_io(DEBUG4,ioh,
@@ -642,18 +650,10 @@ pgaio_io_reclaim(PgAioHandle *ioh)
642650
ioh->distilled_result.error_data,
643651
ioh->result);
644652

645-
/* if the IO has been defined,we might need to do more work */
653+
/* if the IO has been defined,it's on the in-flight list, remove */
646654
if (ioh->state!=PGAIO_HS_HANDED_OUT)
647-
{
648655
dclist_delete_from(&pgaio_my_backend->in_flight_ios,&ioh->node);
649656

650-
if (ioh->report_return)
651-
{
652-
ioh->report_return->result=ioh->distilled_result;
653-
ioh->report_return->target_data=ioh->target_data;
654-
}
655-
}
656-
657657
if (ioh->resowner)
658658
{
659659
ResourceOwnerForgetAioHandle(ioh->resowner,&ioh->resowner_node);

‎src/backend/storage/aio/aio_callback.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,12 @@ pgaio_io_call_complete_shared(PgAioHandle *ioh)
262262
* Internal function which invokes ->complete_local for all the registered
263263
* callbacks.
264264
*
265+
* Returns ioh->distilled_result after, possibly, being modified by local
266+
* callbacks.
267+
*
265268
* XXX: It'd be nice to deduplicate with pgaio_io_call_complete_shared().
266269
*/
267-
void
270+
PgAioResult
268271
pgaio_io_call_complete_local(PgAioHandle*ioh)
269272
{
270273
PgAioResultresult;
@@ -296,13 +299,17 @@ pgaio_io_call_complete_local(PgAioHandle *ioh)
296299

297300
/*
298301
* Note that we don't save the result in ioh->distilled_result, the local
299-
* callback's result should not ever matter to other waiters.
302+
* callback's result should not ever matter to other waiters. However, the
303+
* local backend does care, so we return the result as modified by local
304+
* callbacks, which then can be passed to ioh->report_return->result.
300305
*/
301306
pgaio_debug_io(DEBUG3,ioh,
302-
"after local completion:distilledresult: (status %s, id %u, error_data %d, result %d), raw_result: %d",
307+
"after local completion: result: (status %s, id %u, error_data %d, result %d), raw_result: %d",
303308
pgaio_result_status_string(result.status),
304309
result.id,result.error_data,result.result,
305310
ioh->result);
306311

307312
END_CRIT_SECTION();
313+
314+
returnresult;
308315
}

‎src/include/storage/aio_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ extern void pgaio_shutdown(int code, Datum arg);
309309
/* aio_callback.c */
310310
externvoidpgaio_io_call_stage(PgAioHandle*ioh);
311311
externvoidpgaio_io_call_complete_shared(PgAioHandle*ioh);
312-
externvoidpgaio_io_call_complete_local(PgAioHandle*ioh);
312+
externPgAioResultpgaio_io_call_complete_local(PgAioHandle*ioh);
313313

314314
/* aio_io.c */
315315
externvoidpgaio_io_perform_synchronously(PgAioHandle*ioh);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp