Skip to content

Fix tracing lifecycle and exporter reliability - #1

Open
blast-hardcheese wants to merge 2 commits into
mainfrom
fix-tracing-reliability
Open

blast-hardcheese wants to merge 2 commits into
mainfrom
fix-tracing-reliability

Conversation

@blast-hardcheese

@blast-hardcheese blast-hardcheese commented Sep 18, 2026 •

Copy link
Copy Markdown

What does this PR do?

Makes pg_tracing more reliable during normal query execution, tracing-buffer exhaustion, and collector interruptions. Includes the existing parallel Hash fix plus consistent plan metadata handling, corrected Gather Merge handling, stable nested-span bookkeeping, balanced utility/planner cleanup, and safe omission of unavailable span text. Exported operation names now use the same copied snapshot as the rest of the payload.

Exports have a reloadable 10-second total request timeout (pg_tracing.otel_timeout_ms), and only HTTP 2xx responses count as successful delivery. Failed requests retain their payload for retry. Enables the existing TAP suite in the normal test command and adds lifecycle, parallel-query, small-buffer, and exporter retry coverage.

Motivation

Follow-up reliability maintenance for repeated PostgreSQL process crashes with tracing enabled. The new ordinary workload regression catches a sorted parallel-query failure on the previous pinned revision and passes with this change. This does not establish that every historical production crash had the same cause.

Additional Notes

Validation on PostgreSQL 17.10 ARM64 in an isolated Docker instance:

  • Build succeeds with the repository's warning-as-error settings.
  • All 27 SQL regression cases pass.
  • All 5 TAP files / 27 assertions pass through normal make installcheck.
  • pgindent --diff --check and git diff --check pass.
  • Running the new lifecycle/parallel suite against the previous pinned revision fails; the same suite passes with the patch.

CI passed on PostgreSQL 14, 15, 16, and 17 on x86_64 (run). The exact production PostgreSQL 17.6 image has not been tested locally. Production configuration and deployment are unchanged; broader executor lifecycle redesign remains outside this patch.

Rebuild the database image at the new commit and restart PostgreSQL to load it. No extension SQL upgrade is required; the SQL interface remains at 0.1.0. Do not replace the shared library underneath running PostgreSQL processes, because internal shared-memory span layout changes in this patch.

@adaptcom adaptcom Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confidence Score: 3/5

Summary

Hardens tracing lifecycles and exporter retries. Local PostgreSQL 16 tests and CI 14–17 pass, but executor/shared-memory changes remain high risk and require database-owner review; the exact production image remains untested.

Important Files Changed

File Overview
.github/workflows/run-tests.yml Longer timeout accommodates expanded tests
Makefile Enables TAP tests in the normal test command
doc/pg_tracing.md Documents reloadable timeouts and failed-export retention
expected/parallel.out Expected parallel hash-join results
regress/16/expected/parallel.out PostgreSQL 16 parallel hash-join expectations
regress/17/expected/parallel.out PostgreSQL 17 parallel hash-join expectations
regress/18/expected/parallel.out PostgreSQL 18 parallel hash-join expectations
sql/parallel.sql Sampled parallel hash-join regression
src/pg_tracing.c Balanced nesting, planner cleanup guards, and unavailable-text handling
src/pg_tracing.h Wider nesting indices change internal shared-memory layout
src/pg_tracing_active_spans.c Preserves parent data across active-span array relocation
src/pg_tracing_json.c Operation names use the copied text snapshot
src/pg_tracing_operation_hash.c Initializes hash keys and removes failed text insertions
src/pg_tracing_otel.c Bounds request duration and rejects non-2xx delivery
src/pg_tracing_planstate.c Corrects GatherMerge handling and tolerates missing plan metadata
src/pg_tracing_span.c Accepts explicit text snapshots for operation names
src/pg_tracing_sql_functions.c Passes lock-protected shared text to operation-name lookup
t/004_reliability.pl Covers utility recovery, nesting, parallel execution, and exhausted text buffers
t/005_export_retry.pl Covers HTTP rejection, request timeout, reload, and retry recovery

↻ Re-run review · View in Adapt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant