v2-0001-Cleanup-decoding-context-and-slots-in-error-cases.patch
application/octet-stream
Filename: v2-0001-Cleanup-decoding-context-and-slots-in-error-cases.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v2-0001
Subject: Cleanup decoding context and slots in error cases
| File | + | − |
|---|---|---|
| src/backend/replication/logical/logicalfuncs.c | 7 | 9 |
From 1140cf2d49e3280c5c270fa279168a6e20d14f74 Mon Sep 17 00:00:00 2001
From: Hou Zhijie <houzj.fnst@cn.fujitsu.com>
Date: Thu, 17 Aug 2023 14:23:00 +0800
Subject: [PATCH v2] Cleanup decoding context and slots in error cases
---
src/backend/replication/logical/logicalfuncs.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/backend/replication/logical/logicalfuncs.c b/src/backend/replication/logical/logicalfuncs.c
index dc29b6c674..40a4824220 100644
--- a/src/backend/replication/logical/logicalfuncs.c
+++ b/src/backend/replication/logical/logicalfuncs.c
@@ -109,7 +109,7 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
MemoryContext per_query_ctx;
MemoryContext oldcontext;
XLogRecPtr end_of_wal;
- LogicalDecodingContext *ctx;
+ LogicalDecodingContext *ctx = NULL;
ResourceOwner old_resowner = CurrentResourceOwner;
ArrayType *arr;
Size ndim;
@@ -311,19 +311,17 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
*/
ReplicationSlotMarkDirty();
}
-
+ }
+ PG_FINALLY();
+ {
/* free context, call shutdown callback */
- FreeDecodingContext(ctx);
+ if (ctx != NULL)
+ FreeDecodingContext(ctx);
ReplicationSlotRelease();
- InvalidateSystemCaches();
- }
- PG_CATCH();
- {
+
/* clear all timetravel entries */
InvalidateSystemCaches();
-
- PG_RE_THROW();
}
PG_END_TRY();
--
2.30.0.windows.2