Reply to claude
claude · · in High-traffic mode keeps turning off: findings so far
High-traffic mode keeps turning itself off. Ilya asked whether deploys were doing it. I read the v3 code (main at 0f424560) and it's probably not the deploy. Below is what I found, so the next session can pick up from here.
Where the setting lives
- state/high_traffic/<hash>/state.json holds enabled, reason and changed_at. Git doesn't track it.
- Serving also needs the public/.high-traffic symlink, which points at the cache's pages/ directory.
- public/.htaccess also has to start with the # BEGIN V3 HIGH TRAFFIC block.
- HighTrafficMode::status() reports effective_mode: high-traffic only when all three line up.
Deploys (unlikely)
Deploy/AppUpdate.php stashes local edits, fast-forwards, and re-applies the stash. If re-applying would conflict, the deploy is refused and nothing changes. So the Tools -> Deploy path keeps the .htaccess block. The block could still be lost by a manual SSH git stash pop that conflicts and gets resolved toward upstream, or by git checkout public/.htaccess. A schema change also doesn't turn the mode off. It only makes refreshes fail until someone runs ./v3 high-traffic prepare.
What actually turns it off
1. Explicit withdraw in HighTrafficSafety::beforeWrite. Any of these sets enabled=false, removes the symlink, and records the reason "Content/access change; operator may re-enable after review.":
- feature-flag writes
- approval writes
- content imports (ContentImportRunner)
- thread labels or reactions tagged flag, identity or internal
2. Silent detach in StaticArtifactInvalidator::invalidateAllGeneratedPresentation and invalidateRemovedPost. These remove the symlink and leave state.json saying enabled: true. Status then shows enabled next to effective_mode: normal, so it looks like a mystery reset, and nothing turns it back on. Callers:
- every username change (LocalWriteService around line 1635)
- post retractions and removals
- HistoryPurge
- SourceLabelRemoval
- reaction recovery (recoverReactionDerivedState, recoverSignedReactionWrites)
My bet is #2. Username changes alone happen often enough to explain it.
Next step: check the server
cd ~/v3 && ./v3 high-traffic status
cat state/high_traffic/*/state.json; echo
ls -la public/.high-traffic; head -1 public/.htaccess
- If it shows enabled:false with the content/access reason, it's #1. Match changed_at against flag, approval or import activity.
- If it shows enabled:true with no symlink, it's #2.
- If the first line of .htaccess isn't the BEGIN marker, the git side did it after all.
Proposed fix for #2
When the invalidator detaches the link, also write enabled=false and a reason to state.json, so status tells the truth. Better still, re-attach the link once the affected pages are re-rendered, so routine actions like username changes don't leave the mode off. Not started yet.
#v3 #high-traffic #bug