Skip to content

From v5 stable part 3#390

Merged
mason-sharp merged 6 commits intomainfrom
from-v5_STABLE-part3
Mar 13, 2026
Merged

From v5 stable part 3#390
mason-sharp merged 6 commits intomainfrom
from-v5_STABLE-part3

Conversation

@mason-sharp
Copy link
Member

Bring in changes from v5_STABLE into main, including release notes

danolivo and others added 5 commits March 12, 2026 09:17
Initialize debug_query_string to NULL at apply worker startup, since it
is not a regular backend and has no client query string.

Also clear debug_query_string in execute_sql_command_error_cb after the
errcontext call, which already includes the SQL statement, to prevent it
from appearing a second time in the LOG output.

(cherry picked from commit dab4464)
When spock_read_insert returns NULL (relation not found), the exception
log entry's local_tuple may still hold a pointer from a previous
operation. Clear it before calling log_insert_exception to prevent
get_tuple_origin from dereferencing freed memory.

(cherry picked from commit 5fc70f5)
…ple fix

Phase 1 verifies SUB_DISABLE and skip_lsn recovery when a table is dropped
on the subscriber side.

Phase 2 is a regression test for the dangling local_tuple bug: a conflict
transaction sets exception_log->local_tuple in MessageContext; after commit
MessageContext is reset and the pointer becomes dangling. A subsequent
missing-relation exception in handle_insert() would dereference the freed
pointer (SIGSEGV) without the fix. The test verifies graceful SUB_DISABLE
with no signal 11 in the logs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 351c34f)
Use "local" for the origin when the row is local

Display 0 for local origin in log table

(cherry picked from commit e51bf26)
@mason-sharp mason-sharp requested a review from rasifr March 12, 2026 16:59
@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c9d071f0-62e7-4dc8-93cb-cbc367fe84f3

📥 Commits

Reviewing files that changed from the base of the PR and between b201460 and 951ae4a.

📒 Files selected for processing (1)
  • .github/workflows/spockbench.yml

📝 Walkthrough

Walkthrough

Adds Spock 5.0.6 release notes; fixes cleanup of dangling local_tuple and clears debug_query_string during error handling; adjusts conflict-origin labeling and logging conditions; adds a new missing-relation subscription disable test and three test helper polling functions.

Changes

Cohort / File(s) Summary
Documentation
docs/spock_release_notes.md
Added Spock 5.0.6 (and prior 5.0.5/5.0.4) release notes sections describing new features, perf improvements, bug fixes, and ops notes.
Apply/Runtime fixes
src/spock_apply.c
Clear local_tuple in exception log when relation missing; clear debug_query_string after queued SQL error; initialize debug_query_string on startup. Attention: exception-path memory/state.
Conflict logging
src/spock_conflict.c
Invert local-origin labeling to output "local" for InvalidRepOriginId; relax condition that populates local_origin in conflict log table. Attention: log contents and resolution table values.
Tests — helpers & schedule
tests/tap/SpockTest.pm, tests/tap/schedule
Exported and implemented wait_for_sub_status, wait_for_exception_log, wait_for_pg_ready; added 016_sub_disable_missing_relation to test schedule.
Tests — scenarios
tests/tap/t/016_sub_disable_missing_relation.pl, tests/tap/t/013_origin_change_restore.pl
Added comprehensive test exercising SUB_DISABLE on missing relations and dangling local_tuple regression; added assertion checking origin=local in conflict log. Attention: long-running TAP test and log checks.

Poem

🐰 I hopped through logs and tangled state,
Cleared stray tuples before too late.
Origins now labeled plain and clear,
Tests wait, poll, and chase what's near.
Reboots, skips, and fixes — hop hooray!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'From v5 stable part 3' is vague and does not clearly convey the main changes; it only indicates a branch source without describing what changes are actually being merged. Use a more descriptive title that summarizes the primary change, such as 'Add Spock 5.0.6 release notes and fix local tuple handling in replication' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description 'Bring in changes from v5_STABLE into main, including release notes' is related to the changeset and appropriately indicates a merge from the stable branch with release notes additions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch from-v5_STABLE-part3
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
tests/tap/t/016_sub_disable_missing_relation.pl (2)

46-46: Consider making the log path more robust.

The path "../logs/00${p2}.log" assumes the test runs from tests/tap/t/. This works with the current test harness but could break if the test is run from a different directory.

Consider using the $config->{log_dir} from get_test_config() for consistency:

my $pg_log_n2 = "$config->{log_dir}/00${p2}.log";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/tap/t/016_sub_disable_missing_relation.pl` at line 46, The hardcoded
relative log path in variable $pg_log_n2 is fragile; instead use the test
config's log directory from get_test_config() (the $config hash) to build the
path so it doesn't depend on current working directory—update the assignment of
$pg_log_n2 to reference $config->{log_dir} (use the existing $config from
get_test_config()) and construct the filename with "00${p2}.log".

67-67: Hardcoded sleeps may cause test flakiness.

Multiple sleep(N) calls throughout the test (lines 67, 109, 113, 164, 224) could lead to flakiness under load or slow CI environments. Consider replacing with polling loops where possible, similar to the existing wait_for_sub_status pattern.

For example, line 67's sleep(3) after insert could poll until the row count changes:

# Instead of: sleep(3);
for (1..30) {
    last if scalar_query(2, "SELECT count(*) FROM test_missing_rel") eq '1';
    sleep(1);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/tap/t/016_sub_disable_missing_relation.pl` at line 67, Replace the
hardcoded sleep(3) after the insert with a polling loop that repeatedly calls
scalar_query to check the row count of test_missing_rel (e.g., scalar_query(2,
"SELECT count(*) FROM test_missing_rel") eq '1') with a short sleep between
iterations and a reasonable timeout; mirror the existing wait_for_sub_status
pattern to avoid flakiness under load. Locate the sleep(3) in the test script
and implement the loop, failing the test if the timeout is reached.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/tap/t/016_sub_disable_missing_relation.pl`:
- Line 46: The hardcoded relative log path in variable $pg_log_n2 is fragile;
instead use the test config's log directory from get_test_config() (the $config
hash) to build the path so it doesn't depend on current working directory—update
the assignment of $pg_log_n2 to reference $config->{log_dir} (use the existing
$config from get_test_config()) and construct the filename with "00${p2}.log".
- Line 67: Replace the hardcoded sleep(3) after the insert with a polling loop
that repeatedly calls scalar_query to check the row count of test_missing_rel
(e.g., scalar_query(2, "SELECT count(*) FROM test_missing_rel") eq '1') with a
short sleep between iterations and a reasonable timeout; mirror the existing
wait_for_sub_status pattern to avoid flakiness under load. Locate the sleep(3)
in the test script and implement the loop, failing the test if the timeout is
reached.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 738df693-4bc2-4a06-964a-5205e4b58dbe

📥 Commits

Reviewing files that changed from the base of the PR and between 33a26be and b201460.

📒 Files selected for processing (7)
  • docs/spock_release_notes.md
  • src/spock_apply.c
  • src/spock_conflict.c
  • tests/tap/schedule
  • tests/tap/t/013_origin_change_restore.pl
  • tests/tap/t/016_sub_disable_missing_relation.pl
  • tests/tap/t/SpockTest.pm

In the near future, trim down the schedule and run others
nightly instead.
@mason-sharp mason-sharp merged commit 181c7a6 into main Mar 13, 2026
10 checks passed
@mason-sharp mason-sharp deleted the from-v5_STABLE-part3 branch March 13, 2026 18:01
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.

3 participants