aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2025-03-30 16:10:51 -0400
committerAndres Freund <andres@anarazel.de>2025-03-30 16:27:10 -0400
commitef64fe26bad92a7b8425767cdbbe8b946d4637f0 (patch)
treea76ed73de21d69f9e24fe590e6b207ddfd2b31a9 /src/backend
parentd445990adc419f435360f0dcd91c05c082f5fa3f (diff)
downloadpostgresql-ef64fe26bad92a7b8425767cdbbe8b946d4637f0.tar.gz
postgresql-ef64fe26bad92a7b8425767cdbbe8b946d4637f0.zip
aio: Add WARNING result status
If an IO succeeds, but issues a warning, e.g. due to a page verification failure with zero_damaged_pages, we want to issue that warning in the context of the issuer of the IO, not the process that executes the completion (always the case for worker). It's already possible for a completion callback to report a custom error message, we just didn't have a result status that allowed a user of AIO to know that a warning should be emitted even though the IO request succeeded. All that's needed for that is a dedicated PGAIO_RS_ value. Previously there were not enough bits in PgAioResult.id for the new value. Increase. While at that, add defines for the amount of bits and static asserts to check that the widths are appropriate. Reviewed-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/20250329212929.a6.nmisch@google.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/storage/aio/aio.c2
-rw-r--r--src/backend/storage/aio/aio_callback.c1
2 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/storage/aio/aio.c b/src/backend/storage/aio/aio.c
index 91e76113412..e3ed087e8a2 100644
--- a/src/backend/storage/aio/aio.c
+++ b/src/backend/storage/aio/aio.c
@@ -839,6 +839,8 @@ pgaio_result_status_string(PgAioResultStatus rs)
return "UNKNOWN";
case PGAIO_RS_OK:
return "OK";
+ case PGAIO_RS_WARNING:
+ return "WARNING";
case PGAIO_RS_PARTIAL:
return "PARTIAL";
case PGAIO_RS_ERROR:
diff --git a/src/backend/storage/aio/aio_callback.c b/src/backend/storage/aio/aio_callback.c
index 53db6e194af..b00b6bc1025 100644
--- a/src/backend/storage/aio/aio_callback.c
+++ b/src/backend/storage/aio/aio_callback.c
@@ -83,6 +83,7 @@ pgaio_io_register_callbacks(PgAioHandle *ioh, PgAioHandleCallbackID cb_id,
{
const PgAioHandleCallbacksEntry *ce = &aio_handle_cbs[cb_id];
+ Assert(cb_id <= PGAIO_HCB_MAX);
if (cb_id >= lengthof(aio_handle_cbs))
elog(ERROR, "callback %d is out of range", cb_id);
if (aio_handle_cbs[cb_id].cb->complete_shared == NULL &&