Repository navigation
fix: keep a live agent's address files when the hello fails - #72
Merged
Merged
Conversation
Agent.ensure(true) deleted agent.addr and console.addr before starting a new
agent. When they belonged to an agent another process had just started, or a
busy one, the new agent exited ("an agent already runs") and the live one
was left without addresses until it idle-exited. Now nothing is deleted (the
agent removes stale ones under the store's lock), ensure first asks whether
the address answers (a bare connect), and a start waits until it does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
Agent.ensure(true)ran when the hello to the address in<store>/agent.addrfailed: no answer, a timeout while the agent was still starting, or "the agent refused". It deletedagent.addrandconsole.addrand spawned a new agent. When those files belonged to a live agent (just started by another process, or busy), the new agent exited with "an agent already runs" (the store lock), and the live agent kept the lock with no address files: no app could reach it until it idle-exited (30 min). Seen as anagent.logwith repeated "an agent already runs" lines and onlyotlp.addrleft in the store.The fix
ensuredeletes nothing. The agent itself removes stale address files at startup, under the store's lock; the Python SDK already leaves them alone.ensure(true)first asks whether the address answers (Agent.answers, a bare connect tounix:/tcp:). If it does, the agent is there and no second one starts.start()waits up toSTART_WAIT_MSuntil the address answers, not until the file is non-empty. A unix socket's address is the same path on every restart, so a changed file can't be the signal. If another process's agent wins the race, its address answers and the start counts as done.Sender.handshaketoAgent.connect, which both use.RESTART_MS/failedAtwork as before.Tests
AgentTest:agent.addrandconsole.addrin place, and no second agent starts. This test fails on main.unix:address that nothing listens at: a fakeTRACEPANEL_AGENT_BINwrites a new address a moment later, andensure(true)returns true with that address.answersis a bare connect../gradlew checkis green.