Skip to content

physrep: skip rtcpu'd / decommissioned hosts when establishing reverse connections - #6091

Open
markhannum wants to merge 2 commits into
bloomberg:mainfrom
markhannum:drqs_185361198_revconn_rtcpu
Open

physrep: skip rtcpu'd / decommissioned hosts when establishing reverse connections#6091
markhannum wants to merge 2 commits into
bloomberg:mainfrom
markhannum:drqs_185361198_revconn_rtcpu

Conversation

@markhannum

@markhannum markhannum commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

The physrep reverse-connection path did not consult rtcpu at all. This change makes a node decline to source reverse connections while it is itself rtcpu'd down, enforced on both the sending and receiving sides. A machine that rtcpu reports as down is being routed out of service and should not be handing replication sockets to replicants; replicants can pick up another source. The target replicant's rtcpu state is deliberately left alone.

Background

For cross-cloud physrep (PPCLD -> PDCLD), the replicant often cannot dial out to its source, so the source dials in to the replicant and hands it a socket (a "reverse connection"), which the replicant then uses to pull logs. There are two sides: the sender of reverse connections is the source/intermediary (db/reverse_conn.c), which runs one worker thread per target host and periodically calls send_reversesql_request(); the receiver is the replicant accepting the inbound reversesql appsock (plugins/reversesql/reversesql.c). Neither side consulted rtcpu before this change.

Changes

Sender (db/reverse_conn.c): before initiating a connection, the reverse-connection worker now checks this node's own rtcpu state (gbl_myhostname) and skips initiating while the node is rtcpu'd down, resuming automatically once it is back up. This sits alongside the existing bdb_am_i_coherent() self-gate.

Receiver (plugins/reversesql/reversesql.c): an inbound reversesql request from a source that rtcpu reports as down is rejected — the receiver-side mirror of the sender's self-gate.

The target host's rtcpu state is intentionally not consulted. A replicant that is merely rtcpu'd out of client service but still alive should keep replicating, exactly as it does on the normal (pull) path where the replicant dials out itself. The shared predicate physrep_revconn_host_is_up() is a simple is_node_up(host) == 1 and is now only applied to the sourcing node (self-gate) and the inbound source (receiver).

The predicate is exposed via a new revconn_host_is_up <host> message command for testing.

Testing

Adds physrep_revconn_rtcpu to tests/phys_rep_tiered.test, modeled on the existing physrep_rtcpu_source case. Using the fakedr trap to force rtcpu to report a host as down, it asserts that revconn_host_is_up returns "up" for a healthy host, "down" once the host is marked rtcpu'd, and "up" again after the mark is cleared, and that a node reports itself ineligible to source reverse connections while it is rtcpu'd down (the sender self-gate). Connections use --admin, since the node under test can itself be the one marked rtcpu'd (drtest) and would otherwise refuse normal client traffic.

Notes

This is hardening rather than the root-cause fix. The reverse-connect storm that prompted this was traced to an increase in physrep-fanout on the physrep metadb: each source then services a larger set of reverse-hosts and fans out many more simultaneous outbound connect attempts. That has been addressed separately. This change is defense-in-depth so that a node which has been rtcpu'd down no longer sources reverse connections, regardless of fanout.

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

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
queuedb_rollover_noroll1_generated **quarantined**
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**

@markhannum
markhannum force-pushed the drqs_185361198_revconn_rtcpu branch from 678cb88 to b867609 Compare July 28, 2026 18:03

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

Cbuild submission: Error ⚠.
Regression testing: Success ✓.

The first 10 failing tests are:
ssl_san
sc_parallel_logicalsc_generated
consumer_non_atomic_default_consumer_generated **quarantined**
ssl_set_cmd
ssl_prefer
ssl_dbname
sc_downgrade [timeout] **quarantined**
reco-ddlk-sql [timeout] **quarantined**

@markhannum
markhannum force-pushed the drqs_185361198_revconn_rtcpu branch from b867609 to c6d75fc Compare July 29, 2026 12:44

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

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
sc_resume_logicalsc_generated **quarantined**
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**
reco-ddlk-sql [timeout] **quarantined**

@markhannum
markhannum force-pushed the drqs_185361198_revconn_rtcpu branch 4 times, most recently from a47dcac to 44690f0 Compare July 29, 2026 19:16

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

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**
truncatesc_offline_generated [timeout] **quarantined**
reco-ddlk-sql [timeout] **quarantined**

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

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**

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

Cbuild submission: Error ⚠.
Regression testing: Success ✓.

The first 10 failing tests are:
ssl_san
consumer_non_atomic_default_consumer_generated **quarantined**
ssl_set_cmd
ssl_prefer
ssl_dbname
sc_downgrade [timeout] **quarantined**
reco-ddlk-sql [timeout] **quarantined**

markhannum and others added 2 commits July 30, 2026 11:19
…down node

A node should not act as a physrep reverse-connection source while it is itself rtcpu'd down. The sender (db/reverse_conn.c) now skips initiating reverse connections when this host is rtcpu'd down, and the receiver (plugins/reversesql/reversesql.c) mirrors this by rejecting an inbound 'reversesql' request from a source that rtcpu reports as down. Replicants fail over to another source.

The target replicant's rtcpu state is intentionally NOT consulted: a replicant that is merely rtcpu'd out of client service but still alive should keep replicating, exactly as it does on the normal (pull) path.

This is hardening rather than a root-cause fix -- the reverse-connect storm that motivated it was caused by an increase to physrep-fanout on the physrep metadb (each source servicing a larger reverse-host set), addressed separately.

Also adds a 'revconn_host_is_up <host>' message command exposing the predicate for testing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
Extends tests/phys_rep_tiered.test (physrep_revconn_rtcpu) to exercise the reverse-connection rtcpu predicate via the 'fakedr' hook: revconn_host_is_up reports a host up -> down -> up as it is marked and cleared, and a node reports itself ineligible to source reverse connections while rtcpu'd down (the sender self-gate).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
@markhannum
markhannum force-pushed the drqs_185361198_revconn_rtcpu branch from 44690f0 to 43464ce Compare July 30, 2026 15:19

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

Cbuild submission: Error ⚠.
Regression testing: Success ✓.

The first 10 failing tests are:
sc_resume_logicalsc_generated **quarantined**
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**
reco-ddlk-sql [timeout] **quarantined**

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.

2 participants