more exception barriers#87
Closed
serprex wants to merge 1 commit into
Closed
Conversation
046ed86 to
88c7b00
Compare
88c7b00 to
318b11c
Compare
318b11c to
afbf183
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the exception-barrier approach from #86 by adding additional top-level try/catch guards in the bgworker-facing exporter entry points, aiming to prevent C++ exceptions (especially std::bad_alloc) from crossing PostgreSQL PG_TRY / longjmp boundaries.
Changes:
- Wrap
PschExporterInit()intry/catchto contain exceptions during exporter construction and initial connection. - Wrap
PschExportBatch()intry/catchto contain exceptions during dequeue and export flow. - Wrap
PschExporterShutdown()intry/catchto attempt to contain exceptions during exporter teardown.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+372
to
+377
| elog(DEBUG1, "pg_stat_ch: PschExportBatch() called"); | ||
| StatsExporter* exporter = g_exporter.exporter.get(); | ||
|
|
||
| if (!exporter->IsConnected()) { | ||
| elog(DEBUG1, "pg_stat_ch: client is null, initializing"); | ||
| if (!exporter->EstablishNewConnection()) { |
Comment on lines
+441
to
+447
| // Exception barrier: exporter destructors (clickhouse-cpp socket close, gRPC | ||
| // stub teardown, protobuf arena release) can throw. Catching here prevents the | ||
| // throw from crossing the on_proc_exit chain. | ||
| void PschExporterShutdown(void) { | ||
| g_exporter.exporter.reset(); | ||
| try { | ||
| g_exporter.exporter.reset(); | ||
| } catch (const std::bad_alloc&) { |
afbf183 to
318b11c
Compare
This was referenced May 11, 2026
Member
Author
|
this has NPE problems & is replaced by #94 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
extending #86