Skip to content

pin-proxy: move a connection back to a node that answers again - #10

Merged
sethforprivacy merged 1 commit into
mainfrom
sfp/pin-proxy-rebalance
Oct 26, 2026
Merged

sethforprivacy merged 1 commit into
mainfrom
sfp/pin-proxy-rebalance

Conversation

@sethforprivacy

Copy link
Copy Markdown

pin-proxy.py now moves an MWEB connection back to a Litecoin node once that node is reachable again.

Why

While a node is down, the proxy sends its connection to the other node, which is right. But now that the litecoinds exempt the autoforward hosts from eviction (whitelist=noban), those connections never close, so nothing moved one back. After eu-01's restart on production (2026-10-26), both of each LTC container's P2P connections stayed on usa-01, leaving MWEB dependent on one node until I closed one by hand.

What

Once a minute, if one node holds two or more connections and another holds none:

  • the proxy test-connects to the idle node;
  • if it answers, the proxy closes the busier node's newest connection. mwebd redials, and the least-used-first order sends the redial to the idle node.
  • while the idle node is still down, nothing is closed, so there's no churn.

In normal operation, with one connection per node, the check does nothing and makes no connection.

Tests

tests/test_pin_proxy.py adds two cases:

  • A node is down, so both connections land on the other node. A rebalance changes nothing while the node is down. Once it answers, exactly one connection (the newer) is closed, and the redial lands on the recovered node.
  • With one connection per node, a rebalance leaves everything alone.

The full suite passes (28 tests), as does pyflakes 3.2.0.

Staging (btcpay-usa-dev-01, dry run)

I didn't restart a production litecoind for the test. Staging ran temporarily with MWEB_PEERS set to litecoin-fulcrum-eu-dev-01 and usa-01, and I restarted the dev litecoind:

UTC Each LTC container's :9333 sockets
14:49:09 dev, usa-01
14:49:12 docker restart litecoind on eu-dev-01
14:49:19 – 14:50:40 usa-01, usa-01
14:50:51 dev, usa-01 (logged "answers again; moving a connection")
until 14:55:04 dev, usa-01, with nothing moving

Both mwebds stayed caught up (3202027), and the ltc/ltc-mweb passes logged no errors. Afterwards I redeployed staging on its normal peers (eu-01, usa-01). The LTC wallet volumes were backed up first. Production hasn't been touched.

While a node is down, the proxy sends its connection to another, so one
node ends up with both. Since the litecoinds stopped evicting the
autoforward hosts (whitelist=noban), those connections never close, and
nothing moved one back: after eu-01's restart on 2026-10-26 both of each
container's P2P connections stayed on usa-01 until closed by hand.

Once a minute, if one node holds two or more connections and another
holds none, the proxy test-connects to the idle node. If it answers, the
proxy closes the busiest node's newest connection. mwebd redials, and
the least-used order sends the redial to the idle node. While that node
is still down, nothing is closed.
@sethforprivacy
sethforprivacy merged commit 7d78dcf into main Oct 26, 2026
1 check 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.

1 participant