Skip to content

Print the --transaction pin MOVED/ASK/disconnect warning once - #893

Merged
fcostaoliveira merged 4 commits into
masterfrom
fix/txn-pin-moved-warning-once
Oct 26, 2026
Merged

fcostaoliveira merged 4 commits into
masterfrom
fix/txn-pin-moved-warning-once

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #649.

During a slot migration, a cluster --transaction run printed --transaction pin connection (id=N) received MOVED mid-rotation ... once for every interrupted rotation, which was 431 lines in the issue's 25 s run. m_txn_pin_lost_warned is reset at the start of every rotation, so it only stopped repeats within one rotation.

Each of the three pin warnings (disconnect, MOVED and ASK mid-rotation) now has its own once-per-process flag, so one can't silence another. Each warning's first occurrence is still printed, now ending in (reported once), and the MOVED/ASK counts stay in the MOVED/sec and ASK/sec columns. Only the messages are limited: at the disconnect site, releasing the pin and waking the other connections still happen once per rotation under m_txn_pin_lost_warned, as before. Like the missing-owner warning, these are once per process, including across --run-count runs.

Test: test_transaction_moved_warning_printed_once in tests/test_cluster_slots_bad_reply.py. Its scripted one-node cluster answers every 3rd SET of a --transaction MULTI/SET/EXEC run with -MOVED (to itself). With master's cluster_client.cpp the warning is printed 33 times, and with this change once.

Sanitized make check passes, the test file passes 21/21, and clang-format is clean.

🤖 Generated with Claude Code


Note

Low Risk
Logging-only change with existing pin-release behavior preserved; covered by a new integration test.

Overview
Fixes #649: cluster --transaction runs during slot migration no longer flood stderr with repeated pin warnings.

m_txn_pin_lost_warned still resets each rotation and drives pin release / sibling wakeups as before; only the log lines are gated by three separate once-per-process std::atomic<bool> flags (disconnect, MOVED, ASK mid-rotation). Each warning still fires on first occurrence, now ending with (reported once); MOVED/ASK rates in stats are unchanged.

Adds test_transaction_moved_warning_printed_once, which scripts every 3rd SET as -MOVED and asserts a single received MOVED mid-rotation line.

Reviewed by Cursor Bugbot for commit 172dc7e. Bugbot is set up for automated code reviews on this repo. Configure here.

m_txn_pin_lost_warned was reset at every new rotation, so a slot
migration printed one "pin connection received MOVED mid-rotation"
warning per interrupted rotation: 431 lines in a 25 s run. The MOVED and
ASK counts are already in the stats; print each run's first one only,
and say so in the message.

The test answers every 3rd SET of a --transaction run with -MOVED from a
scripted one-node cluster; master prints the warning 33 times.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

🤖 Automated first-pass review — a human maintainer's review is still required before merge.

Thanks for this. The fix is small and the test fails on master (33 warnings) and passes here (1), which is the bar we want. A couple of questions:

  • I think there's one behavior change here that isn't only about the message. Before this PR, the MOVED/ASK sites also set m_txn_pin_lost_warned = true. Now they don't. Take a MOVED or ASK on the pin while is_multi_open() is true: the pin is deliberately kept (Cluster --transaction: CLUSTER SLOTS sent inside an open MULTI wedges the main connection #569), and the flag now stays false. If that pin connection then disconnects in the same rotation, hold_pipeline() will now run txn_release_pin() and wake the other connections. Before, it skipped that because the flag was already set. That's probably an improvement, since the old path could leave the rotation pinned to a dead connection. But it doesn't match "as before" in the description. Was this intended? If so, I'd mention it in the commit message, and a test for it would be nice.
  • Nitpicking: after this change m_txn_pin_lost_warned only guards the disconnect-site release/wake-up bookkeeping, not any warning. A name like m_txn_pin_lost_handled would be less confusing for the next reader.
  • Nitpicking: the new test only covers MOVED. The ASK and disconnect sites got the same change with their own flags. I'm not asking for more scripted-node tests if they're awkward to set up, just checking that the gap is intentional.

Once-per-process with exchange(true) matches how the missing-owner warning already works (cluster_client.cpp:548), so the --run-count behavior is consistent. Apart from confirming the first point, this looks good to me.

(would file this as a comment, not a formal block)

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1eea7a7. Configure here.

Comment thread cluster_client.cpp Resolved
fcostaoliveira and others added 2 commits October 25, 2026 16:22
The once-per-process flag also gated the disconnect site's pin release
and wake-up of the other connections in hold_pipeline(), not just the
log line. Keep that bookkeeping on the per-rotation m_txn_pin_lost_warned
and gate only the message. Give the disconnect, MOVED and ASK warnings
their own flag so one cannot silence the others, and say "rotations":
later interrupted rotations are inaccurate too. The test also checks the
exit code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On master a MOVED or ASK on the pin sets m_txn_pin_lost_warned, which
also makes a disconnect of that pin later in the same rotation skip the
release in hold_pipeline(). Keep that, so only the messages differ from
master.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Good catch, that wasn't intended. Fixed in 172dc7e: the MOVED and ASK sites set m_txn_pin_lost_warned = true again on every pin MOVED/ASK, as on master. A disconnect of that pin later in the same rotation therefore skips the release in hold_pipeline() exactly as before. With this, the only difference from master is that each of the three messages is printed once per process. Whether releasing the pin there would be better is a separate behaviour change, and it doesn't belong in a log-spam fix. On the name: it still guards that release as well as the disconnect warning, so I've kept it to avoid widening the diff. On the test: only MOVED is covered. The ASK and disconnect sites use the same pattern with their own flags, and the scripted node has no ASK mode. Sanitized test_cluster_slots_bad_reply.py passes 21/21.

@fcostaoliveira
fcostaoliveira merged commit 8b0ed24 into master Oct 26, 2026
68 of 69 checks passed
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.

Cluster --transaction: 'pin connection received MOVED mid-rotation' warning is printed once per rotation during a slot migration (hundreds of lines)

1 participant