Repository navigation
AI-3878: a message waits one second at most for the node directory - #2471
Conversation
kanat
left a comment
There was a problem hiding this comment.
VERDICT: GO
Reviewed 65c70b4 merged onto main 05cafd6 (clean). CI on the head: every integration job passes; go fails TestRefusedAttemptsSuite in keypool, a known base failure (#2500), not this PR.
Checked and sound: the 1 s limit is a WithTimeout of the caller's ctx, so it never outlasts it, and cancel is deferred. The read runs in a goroutine with a buffered channel and ends with the derived ctx. A bound hit answers here and logs a Warn with the agent and the error, so no message is lost silently. The three new tests and CannotBeRead passed 5 of 5 with -count=5 at machine load ~28. The mutants I tried were killed: no limit, 2 s, 650 ms, 400 ms, true on the read error, an unbuffered channel, no ctx.Done() case, the read outside the goroutine, WithoutCancel. One survived (R1.1). #2402 is not on main, so there is no InTime to compare with.
Outside the diff:
[Question] R1.3 A message with no session on this node still waits without a limit. answeringNode (forward.go:387/389, reached by forwardedMessage at messagehooks.go:414) and Waiting in forwardedToWorkers (forward.go:432, messagehooks.go:456) read the directory with the hook's ctx. The title says a message waits one second at most, which holds only for the writesElsewhere read. The body lists nodeFor and forwardedToWorkers as follow-ups but not answeringNode. Ticket all three, and consider rewording the title to the one read.
Details: reviewer-1.md in the ledger.
kanat
left a comment
There was a problem hiding this comment.
Approving on the reviewer's GO.
kanat
left a comment
There was a problem hiding this comment.
Re-approving: the new commits merge main and change only tests (checked).
Problem
writesElsewhereasks the node directory whether another customer's session writes as the agent, before the session running here answers a message that names no customer. The read had no limit of its own, and rueidis retries a read until its context ends. With a Redis that takes the command and never answers, the message was not answered in the test's 10 s. The fallback, answering here when the directory cannot be read, was not reached.Fix
writesElsewherewaits one second for the directory, then answers here as for any other failed read. A directory that takes longer than a second to answer now counts as one that cannot be read.node.Directory.answeringNode's caller hands the message to a worker on an error, andhandDeliveryToPeerreopens the session, so with these two a short limit could start a second session while a slow Redis still knew of the first. They are unchanged.nodeForandforwardedToWorkersstill read without a limit.Tests
TestAMessageNamingNoCustomerIsAnsweredHereInTimeWhenTheDirectoryHangs: a Redis that drops every answer, the hook answered in under 1.5 s and the session asked. Without the limit it fails:context deadline exceeded (Client.Timeout exceeded while awaiting headers). It also fails with a 1.9 s limit, and withreturn trueon the read error.TestAMessageNamingNoCustomerIsAnsweredHereInTimeWhileAnotherReadDialsTheHungDirectory: the same while a read without a limit dials the connection again, and the goroutine ends once that dial does. With the read outside a goroutine it fails:"5.00055825s" is not less than "2s". With an unbuffered channel, or the read oncontext.WithoutCancel, it fails:what asked the directory is still running.TestAMessageNamingNoCustomerIsAnsweredByNeitherThoughTheDirectoryIsSlow: answers 700 ms late are still waited for. Fails with a 400 ms limit.TestARenewedClaimOnAnAgentIsInItsSessionsApp: a renewal keeps the app of a claim. It is here because the ticket asks for it: storing app 0 ind.held, which the renewal reads, passed every suite. Fails whenHoldkeeps app 0 ind.held.Fixes AI-3878