Repository navigation
M7 audit, part 1: the error model - #38
Merged
Merged
Conversation
The first part of M7's audit (docs/7-api.md §6): the kinds that reach the application follow the spec's categories (error-model §2-§3) and Java V5's mapping, and the docs say what each operation fails with. Kinds: - A broker's ConsumerAssignError is ConsumerBusy, InvalidTxnStatus and TransactionNotFound are TransactionConflict, as Java V5 maps them; InvalidTopicName is InvalidConfiguration. They were Other. - A broker that refuses the handshake when a producer or a consumer registers on a segment, as for credentials it rejects, fails the registration with its refusal, as a lookup does. It counted as no broker to ask: retried until the operation timeout, then Timeout. - An authentication provider's failure is Authentication, with the provider's error as its source, as in Java V5. It kept the provider's own kind, retried or not by it. - A controller URL from the broker that doesn't parse is a malformed answer, not the application's InvalidServiceUrl. Durations: Duration::MAX, or any duration too long for a deadline, panicked in receive_timeout, receive_batch, the send timeout, the batching delay, the ack group time and the keepalive interval, and hung create() for the operation and connect timeouts. Durations are capped at a year, which macOS's event loop takes (it refuses a wait of 68 years or more). deliver_after saturates at the latest time its field holds. Docs: each ErrorKind says what it means and whether the client retries it; every fallible operation of the producer, the consumers, the clients and the decoders lists the kinds it fails with; docs/7-api.md §6 lists Other, the mapping and the retry rule.
- event_loops(usize::MAX) panicked as the thread-safe client reserved room for every loop up front (capacity overflow). The loops are grown one by one: a count too large to start fails as the threads run out, with Other. - initial_sequence_id(i64::MAX) overflowed computing the next id, a panic in a debug build. The next id is a u64, as on the wire, after the initial one or the broker's last.
With the first commit, credentials the broker refuses, or a provider can't supply, fail a segment's registration at once. For a producer already registered on the segment, registering again after a lost connection, that failed every message queued there: one failed token fetch lost them, where a retry may find fresh credentials. Such a producer now retries them as it retries the connection, its messages bounded by the send timeout; a first registration still fails with them, as a lookup does. Running consumers already subscribe a segment again after a backoff.
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 first part of M7's audit: the error model (
PLAN.md, M7;docs/7-api.md§6). Rustdoc and the examples followin their own pull requests.
Problem
Some failures reached the application under a kind that doesn't match the spec's categories (error-model §2–§3)
or Java V5's mapping (
V5ExceptionMappings), and the docs didn't say what an operation fails with.ConsumerAssignError(Key_Shared ranges that overlap anotherconsumer's) came out as
Other; Java V5 makes itConsumerBusy.InvalidTxnStatusandTransactionNotFoundcameout as
Other; Java V5 makes themTransactionConflict.InvalidTopicNamecame out asOther, though only theapplication can change the name.
broker that refuses the connection, as for credentials it rejects, counted as no broker to ask: the client retried
until the operation timeout and reported
Timeout. A lookup reports the same refusal at once, asAuthentication,which error-model §3 says the client doesn't retry.
Token::from_fncallback that failed withConnectwas retried for the whole operation timeout and ended asTimeout; one that failed withOthercame outas
Other. Java V5 reports a provider's failure as an authentication failure.Duration::MAX, or any duration too long for a deadline, panicked with an overflow inreceive_timeout,receive_batch, the send timeout, the batching delay, the ack group time and the keepaliveinterval, and hung
create()for the operation and connect timeouts.docs/7-api.md§6 says nothing in the APIpanics on bad input. Short of the overflow, macOS's event loop refuses a wait of 68 years or more, and compio panics
on that. Two other inputs panicked too:
event_loops(usize::MAX), as the client reserved room for every loop upfront, and
initial_sequence_id(i64::MAX), whose next id overflowed in a debug build.ErrorKind's variants had no docs,docs/7-api.md§6 didn't listOther, and no operationsaid which kinds it fails with.
Example
The refused handshake, in
RegisterError::from(Error):Error::server_error()only read a broker's refusal of arequest or a lookup, so
ConnectionError::Refused { AuthenticationError }becameRegisterError::Unavailable, whichthe producer and the consumers retry.
Change
server_error_kind:ConsumerAssignErrorisConsumerBusy,InvalidTxnStatusandTransactionNotFoundareTransactionConflict, andInvalidTopicNameisInvalidConfiguration.Error::server_error()reads a refused handshake too, when its kind is one the client doesn't retry. A refusalit retries, such as
ServiceNotReady, is still a failure to connect, as for a lookup.RegisterError::fromturnsany other authentication failure (a provider's, too many challenge rounds) into the broker's
AuthenticationError,which isn't retried. A create, a subscribe and a producer's first send to a segment now fail with the refusal at
once, as a lookup does. A producer already registered on the segment, registering again after a lost connection,
retries refused credentials as it retries the connection, so that one failed token fetch doesn't fail the messages
queued there; running consumers already subscribe a segment again after a backoff.
Authentication, with the provider's error as its source.and batching delay, a consumer's ack group time and negative-ack delay, and the receive timeouts.
Duration::MAXmeans "as long as it gets".
deliver_aftersaturates at the latest time its field holds.Otheras the threadsrun out. The next sequence id is a
u64, as on the wire, after the initial one or the broker's last.Other), not the application'sInvalidServiceUrl.ErrorKindsays what it means and whether the client retries it;Errorsays how it prints and whereits source is; every fallible operation of the producer, the three consumers, the clients and the decoders says
which kinds it fails with.
docs/7-api.md§6 listsOther, the mapping choices and the retry rule.Testing
New tests: the broker codes' kinds; a refused handshake found in an error, and turned into a registration's refusal
or not; a Shared producer's send through a segment broker that refuses the credentials, which fails with
Authentication; a failing token provider, which fails a lookup withAuthenticationand keeps its error as thesource; and a client, a producer and a Queue consumer with
Duration::MAXeverywhere, which produce, receive andacknowledge; a loop count of
usize::MAX, which fails the build withOther; and a Shared producer whose initialsequence id is
i64::MAX, whose first message gets 2^63; and a registered segment's producer whose nextregistration is refused the credentials, whose waiting message is stored once a retry succeeds. Each fails without its fix.
cargo test --workspace, clippy for both feature sets, rustdoc with-D warningsand coverage(measured as CI does) pass locally.