docs(gochannel): GuaranteedOrder is not supported by default - #698
Open
baltasarblanco wants to merge 1 commit into
Open
baltasarblanco wants to merge 1 commit into
baltasarblanco wants to merge 1 commit into
Conversation
The characteristics table has claimed GuaranteedOrder since 043c41b (2019-07-07), but the test suite has declared GuaranteedOrder: false for gochannel since the flag was introduced in 577f2ac (2019-08-07), so the ordering assertions in pubsub/tests/test_pubsub.go have never run against it. sendMessage spawns a goroutine per message per subscriber, so the order in which messages reach the subscriber is up to the scheduler. Publishing 0..7 in order to a single subscriber arrives out of order on every run. Setting BlockPublishUntilSubscriberAck preserves order as long as a single goroutine is publishing. Refs ThreeDotsLabs#692
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.
Motivation / Background
The Go Channel characteristics table lists
GuaranteedOrder | yes, but gochannel does not guarantee order with its default configuration, and the test suite has never claimed it did.The table entry dates back to 043c41b (2019-07-07). The
GuaranteedOrderflag was introduced into the gochannel tests a month later, in 577f2ac (2019-08-07), already set tofalse, and it has beenfalseever since — inpubsub_test.goandpubsub_stress_test.goalike. Because of that, the ordering assertions inpubsub/tests/test_pubsub.go(TestPublishSubscribeat line 410 and the consumer group test at line 538) have never run against gochannel.Every other Pub/Sub in the docs matches its test suite on this flag —
sql.mdsaysyesandwatermill-sqlsetsGuaranteedOrder: truein all six of its test invocations, for example. gochannel is the only one where the table and the tests disagree.Refs #692.
Detail
Measured on v1.5.3, publishing 0..7 in order to a single subscriber, eight consecutive runs:
Out of order in every run with the default config.
sendMessage(pubsub/gochannel/pubsub.go:164) spawns a goroutine per message per subscriber, so the order in which they reachs.sendingis up to the scheduler.BlockPublishUntilSubscriberAckmakesPublishwait for each message to be acked before sending the next one, which preserves order as long as a single goroutine is publishing. With several publishing goroutines it reorders again.OutputChannelBufferandPersistentmake no difference either way.This changes the table entry to
noand adds a note describing the case where order is preserved, in the style of the existingkafka.mdnote about partition keys.Alternative approaches considered (if applicable)
Making gochannel guarantee order by default would be the other way to resolve the mismatch, but that is a behaviour change rather than a documentation fix, and it would have to be reconciled with the test suite's current expectations. Happy to defer to you if that is the direction you'd prefer — in the meantime the table should describe what the implementation actually does.
Checklist
GuaranteedOrder: false.make test_shortandmake test_racepass on this branch (Go 1.27.1, Linux amd64).