Skip to content

Fix pg_receive_wal_test race condition and handle postgres shutdown NoticeResponse#47

Draft
Copilot wants to merge 7 commits into
masterfrom
copilot/replace-brotli-dependency-go
Draft

Fix pg_receive_wal_test race condition and handle postgres shutdown NoticeResponse#47
Copilot wants to merge 7 commits into
masterfrom
copilot/replace-brotli-dependency-go

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 26, 2026

wal-verify integrity was running while wal-receive was still actively streaming, causing segments to appear as MISSING_UPLOADING (→ WARNING) instead of FOUND (→ OK). Additionally, wal-receive would crash with "Received unexpected message" when postgres sent a NoticeResponse on shutdown.

Changes

docker/pg_tests/scripts/tests/test_functions/test_receive_wal.sh

  • Stop postgres with -m fast before running wal-verify, so all WAL has been generated before checking
  • Capture wal-receive PID and wait for it to finish uploading remaining segments before verifying
  • Drop the unreliable sleep 1
# Before: verify while still streaming → MISSING_UPLOADING
wal-g wal-receive &
pgbench ...
sleep 1
wal-g wal-verify integrity   # races with active streaming
pg_ctl stop -m immediate

# After: verify after everything is flushed
wal-g wal-receive &
WAL_RECEIVE_PID=$!
pgbench ...
pg_ctl stop -m fast
wait $WAL_RECEIVE_PID || true
wal-g wal-verify integrity

internal/databases/postgres/wal_segment.go

  • Add a *pgproto3.NoticeResponse case to processMessage(): log it as a warning and return OK instead of treating it as a fatal unexpected message. Postgres sends this notice before closing a replication connection on clean shutdown.
Original prompt

This section details on the original issue you should resolve

<issue_title>[FEATURE] replace brotli dependancy with pure go implementation</issue_title>
<issue_description>### What feature would you like?

Currently the brotli dependency is based on the CGO wrapper of brotli (https://github.com/google/brotli/tree/master/go) maybe just for historical reasons.

But now it exists a pure Go implementation https://github.com/andybalholm/brotli that does not need to have all the burden of linking and maintaining the submodule of the CGO wrapper.

Why is this feature useful?

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

chipitsine and others added 2 commits February 15, 2026 14:35
it has issues with checkout fixed in current master
Copilot AI and others added 2 commits February 26, 2026 08:04
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace brotli dependency with pure Go implementation Replace CGO brotli dependency with pure Go implementation Feb 26, 2026
Copilot stopped work on behalf of chipitsine due to an error February 26, 2026 09:01
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot AI changed the title Replace CGO brotli dependency with pure Go implementation Remove obsolete brotli CGo sed patch from pg_tests Dockerfile Feb 26, 2026
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot AI changed the title Remove obsolete brotli CGo sed patch from pg_tests Dockerfile Remove obsolete brotli CGo sed patches from Dockerfiles Feb 26, 2026
…ceResponse gracefully

Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot AI changed the title Remove obsolete brotli CGo sed patches from Dockerfiles Fix pg_receive_wal_test race condition and handle postgres shutdown NoticeResponse Feb 26, 2026
@chipitsine chipitsine force-pushed the master branch 2 times, most recently from 3633c51 to 81395bd Compare May 7, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] replace brotli dependancy with pure go implementation

2 participants