Skip to content

Tor stuck at 95% for an hour after a restart: rotate guards instead of restarting (relay circuit-creation defence) #4121

Closed
0 of 1 issue completed

Description

@pithead-developer

What's the problem

After a Tor restart, a Pithead stack can sit at "Bootstrapped 95% (circuit_create)" for about an hour. The guard connection is open, but no circuit-create gets an answer. Restarting Tor again does not help. Moving Tor's state file aside, which makes Tor pick new guards, fixes it within seconds.

Three bench cases on 2026-11-15:

  • Node bench A: the healer restarted Tor at 04:59:57Z. Tor stayed at 95% for 62 min, then monerod wedged until it was restarted alone.
  • Node-serving bench: an e2e restarted Tor at 09:46:57Z. Tor stayed at 95% until 10:38:07Z (51 min). The e2e's baseline restore at 09:58Z failed with dependency failed to start: container tor is unhealthy, which left monerod and tari in state Created and blocked every node-reading KVM job for about 50 min.
  • Third bench: about 1 h at 95% after its own restart (noted during the first incident).

Tor's build summary during the stall shows every abandoned circuit stuck at the first hop with the channel open (for example prefix_hops_0=21 open_channel=21 completed=10 abandoned=21). The guards also logged "is failing a very large amount of circuits". Five minutes after bootstrap finished, the same Tor showed completed=636 abandoned=16.

Likely cause (an inference, not yet tested): the guard relay's circuit-creation DoS defence. The current consensus (valid-after 2026-11-15 10:00) sets DoSCircuitCreationEnabled=1, DoSCircuitCreationMinConnections=2, DoSCircuitCreationRate=2 and DoSCircuitCreationBurst=60. That is tighter than Tor's defaults of 3, 3 and 90. It does not set DoSCircuitCreationDefenseTimePeriod or DoSCircuitCreationDefenseType. The tor manual gives their defaults as 3600 s (each activation lasts a random 60 to 90 min) and type 2 ("refuse circuit creation"). All of these apply per client IP address. A client address with at least 2 connections to a relay that sends more than 60 creates in a burst has its creates refused for that period. A cold start sends that kind of burst: preemptive circuits plus isolated streams for monerod, tari and P2Pool. So does several Tor clients sharing one public address and the same popular guard, such as a host's stack plus test guests. Keeping the same guards keeps the refusal; new guards have not flagged the address.

What it impacts

  • Any Pithead install whose Tor is restarted by the healer, an upgrade, a reboot or an e2e: monerod, tari and P2Pool lose Tor for up to an hour. Alerts travel over Tor, so the outage is silent.
  • Restart-based self-heal can make it worse: each restart is a new burst, and the restart keeps the refusing guards.
  • On the bench fleet, the node-serving bench's restore fails and node-reading KVM jobs stall until the refusal ends.

How I found it

  • The Tor logs and build summaries on the benches named above (2026-11-15).

  • The consensus params line cached by the node-serving bench's Tor.

  • The operator's earlier records of a 95% stall cured by moving state aside:

    • 2026-10-06: 100% in about 10 s;
    • 2026-10-22, after an e2e, with zero completed circuits: healthy in 30 s;
    • twice more on 2026-10-22, for first-hop failures.

    2026-09-26, 2026-10-10 and 2026-10-12 had the same cure, but their state file was also saturated, so they are weaker evidence.

How important is it

High, but not a v2.0.4 blocker. It turns every Tor restart into a possible one-hour outage, and the self-heal work in #4075 (PR #4095) uses restarts as rungs. #4095 needs no change for this. This issue adds the rung that fits this signature.

Acceptance criteria

  • The healer recognises the hop-0 refusal signature. Bootstrap stays at circuit_create, or circuit-established is 0, while at least one guard channel is open and circuits are abandoned at the first hop. This lasts at least N minutes after a Tor start, where N is one named constant.
  • On that signature the next rung is guard rotation, not a restart: the control-port DROPGUARDS command or the existing state reset. A restart is not used for this signature. Each rotation is audited and capped per day.
  • A unit test on the healer's decision with a fake clock and fake control-port readings: hop-0 signature, then rotation; circuits completing, then no action.
  • A KVM or fault-injection leg drops circuit-create cells at the guard but not the TCP channel. It asserts that the stack reaches working Tor egress within the bounded window without a Tor restart.
  • The test is written so it can confirm or refute the DoS-defence explanation. Record whether rotation alone cures the fault, and how long an untouched Tor takes to recover.

Possible solutions

  • Use DROPGUARDS over the control port the healer already uses. It needs no container restart and keeps onion keys. Tor warns that it weakens guard protection, so cap it per day and audit it.
  • Reduce the start-up burst: stagger monerod, tari and P2Pool after Tor reaches 100%, and review stream isolation so a cold start opens fewer circuits.
  • On the bench fleet, wait for Tor's health before the baseline restore's docker compose up, bounded by a timeout. bench-ci's automatic wallet recovery already retries once Tor is healthy. On 2026-11-15 it restored the node-serving bench by itself at 10:50Z.

Sub-issues

Sub-issues

0 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    operator-action
    on Nov 15, 2026
  2. added this to the v2.0.5 milestone on Nov 16, 2026
  3. added
    blocked
    on Nov 16, 2026
  4. pithead-developer commented on Nov 16, 2026

    @pithead-developer
    ContributorAuthor

    Blocked on #4075.

    Placed in v2.0.5: bugs go to the next patch, and this was never a 2.0.4 blocker. It changes the same Tor auto-heal ladder as #4075 (PR #4095), so it starts after that lands. Constraints from the owner's rulings on #4075: the guard-rotation rung counts against the same cap and per-day budget, and no new disruptive rung runs after the cap. Use the bench-ci#2535 canary for the DROPGUARDS stream check rather than a second proof, and keep any fault-injection KVM leg under the 24 h benchmark limit.

  5. removed
    operator-action
    on Nov 16, 2026
  6. added
    P1-user-facing
    on Nov 20, 2026
  7. removed
    blocked
    on Nov 21, 2026
  8. pithead-developer commented on Nov 21, 2026

    @pithead-developer
    ContributorAuthor

    Questions before work continues (answer here, then remove the question label):

    The issue's acceptance criterion for a KVM or fault-injection leg that drops circuit-create cells at a guard while the TCP channel stays open is not met, and no row in job 712 exercises DROPGUARDS. I found no way to drop circuit-create cells without dropping the TCP channel on a guest. May I close this PR as the host and healer change, with unit and stack tests plus the e2e run, and file one follow-up issue for the fault leg and the record of whether rotation alone cures the stall? Default: yes, because the follow-up needs a design for the fault injection that I cannot verify without bench time.

  9. added
    question
    on Nov 21, 2026
  10. pithead-architect commented on Nov 21, 2026

    @pithead-architect

    Ruling: Yes, split it, but on these conditions, in this order. (1) File one follow-up issue on maintenance & gates using the six required sections. Quote #4121's acceptance lines 4 and 5 word for word: the fault leg that refuses circuit-create cells while the channel stays open, and the record of whether rotation alone cures the stall and how long an untouched Tor takes to recover. Link it to #4121 as a native sub-issue. In its Possible solutions, offer this as an untested option: a private Tor network on a guest whose guard relay runs with a deliberately low DoSCircuitCreation* torrc (enabled, minimum connections 1, a small burst, defence type 2). That would produce refused creates on an open channel and would also test the DoS-defence hypothesis directly. Also list the healer's tor-dropguards audit records from the benches after deploy as a natural record of time-to-bootstrap. (2) In the PR body, list the split under "Decisions taken". Replace the unchecked fault-leg item with "moved to #N", not "needs a decision". Keep Part of #4121 until that follow-up exists, then let the runner's closing keywords handle #4121. (3) The diff changes tests/os/tor-heal-guest.sh, which tests/os/phases/tor-heal.sh runs, and the healer that phase exercises. That is a battery change, so before ready it needs one tier4-kvm job running the tor-heal phase on the current head, with its bench-ci evidence pasted unedited. Return waiting with the job in bench_jobs until it completes. (4) Job 712's one red row shows "no issue linked". Name #2890 as that row's owner in the body. Row-scoped evidence then lets this PR proceed on its 155 green rows. Do not re-run the e2e for it. The adversarial review remains the merge gate.

  11. removed
    question
    on Nov 21, 2026
  12. pithead-developer commented on Nov 23, 2026

    @pithead-developer
    ContributorAuthor

    Merged in #4339.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-user-facing

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions