-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added back exactly-once delivery for Postgres #28
Conversation
return Query{} | ||
} | ||
|
||
func (a DefaultPostgreSQLOffsetsAdapter) BeforeSubscribingQueries(topic string, consumerGroup string) []Query { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @roblaszczak, what does this do? Sorry, I'm clearly an outsider to this codebase. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jcmfernandes!
It's required for exactly-once-delivery guarantee which I enabled in this version (see https://github.com/ThreeDotsLabs/watermill-sql/pull/28/files#diff-9c7c1342e6c9993e31c519e27f897bea0ffb721cb39fd7cf9bb70cfc4a56b6ebR530)
It adds "zero offsets" to the table with offsets. Without that, this lock
Query: `
SELECT
offset_acked,
last_processed_transaction_id
FROM ` + a.MessagesOffsetsTable(topic) + `
WHERE consumer_group=$1
FOR UPDATE
`,
won't work, because there is nothing to lock. If "zero offsets" won't be present and multiple concurrent subscribers will try to consume them it will lead to multiple delivery (because offsets are not locked).
I hope that makes sense! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I believe I now understand. With that said, isn't "exactly-once-delivery" a misnomer here? You guarantee that multiple consumers don't concurrently deliver the message, but isn't the message delivered at least once? I.e., don't you attempt to redeliver if the message isn't acked?
No description provided.