Skip to content
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

feat(pubsub): support exactly once delivery #6506

Merged
merged 31 commits into from Aug 22, 2022

Conversation

hongalex
Copy link
Member

@hongalex hongalex commented Aug 11, 2022

The pubsub-exactly-once branch has code that has been reviewed in individual PRS already.

* feat(pubsub): read exactly once for SubscriptionProperties

* rename vars to be specific this is exactly once delivery
…oogleapis#6157 (googleapis#6162)

* add RWMutex for guarding exactly once bool

* feat(pubsub): send stream ack deadline seconds on exactly once change

* remove extra test
…apis#6201)

* add AckResult and related methods

* feat(pubsub): add AckWithResult and NackWithResult to message

* feat(pubsub): add AckWithResult and NackWithResult to message

* add comments for AckResult and bring over AcknowledgeStatus from internal

* update function definition for IgnoreExported in tests

* temporarily update internal/pubsub for samples test

* change enum naming to AcknowledgeStatus

* remove extra enums in temp internal message.go

* remove internal/pubsub/message.go

* fix style issues with variadic function options

* add back comment format to exported const

* keep track of AckResults if exactly once is enabled
* add AckResult and related methods

* feat(pubsub): add AckWithResult and NackWithResult to message

* feat(pubsub): add AckWithResult and NackWithResult to message

* add comments for AckResult and bring over AcknowledgeStatus from internal

* update function definition for IgnoreExported in tests

* temporarily update internal/pubsub for samples test

* add process results

* change enum naming to AcknowledgeStatus

* remove extra enums in temp internal message.go

* remove internal/pubsub/message.go

* add process results

* update process info with new enum names

* add tests to process error info

* add process results

* update process info with new enum names

* add process results

* add tests to process error info

* clean up iterator from merge

* cleanup comments

* add list of retriable errors to test

* simplify testing of completed/retry slice lengths

* remove getStatus/ackErrors methods

* address code review comments

* remove error string conversion step
* refactor sendAck to pipe errors to AckResult map

* rewrite sendAck/sendModAck for exactly once

* add AckResult to list of uncompared methods

* use ackResultWithID in all locations
* retry acks in goroutine

* retry acks/modacks with transient errors

* add retry test

* add nack tests and support shorter timeouts

* add integration tests

* remove extra comment

* add commnets to ack/modack methods in iterator
@hongalex hongalex requested review from a team as code owners August 11, 2022 21:34
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: pubsub Issues related to the Pub/Sub API. labels Aug 11, 2022
}
// If exactly once is enabled, keep track of all pending AckResults
// so we can cleanly close them all at shutdown.
it.eoMu.Lock()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any concern about performance impact to non exactly once delivery subs due to these locks, here and below?

can the critical section be reduced if we read the value of it.enableExactlyOnceDelivery into a local variable inside a reader lock, and then execute the rest of the logic using that variable? Would that impact the logical correctness?

Copy link
Member Author

@hongalex hongalex Aug 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the lock acquisition should've been a RLock() + RUnlock() here and outside of the loop. I made a similar optimization (moving the mutex locking) in other places as well. The only place where the mutex is locked for writing is when receiving on the stream so impact on non-exactly once subscriptions should be minimal.


const (
transientErrStringPrefix = "TRANSIENT_"
transientInvalidAckErrString = transientErrStringPrefix + "FAILURE_INVALID_ACK_ID"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should never happen. Invalid ack id is a permanent failure, always. I do not see this variable used anywhere apart from tests so maybe the logic is right, just that we don't need this variable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I wasn't aware of this. I was mostly copying Python's error strings though I removed the variable anyway and made it a generic "TRANSIENT_FAILURE" error string for tests.

@hongalex hongalex added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 14, 2022
@hongalex hongalex added kokoro:run Add this label to force Kokoro to re-run the tests. and removed kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Aug 15, 2022
@hongalex hongalex added kokoro:force-run Add this label to force Kokoro to re-run the tests. and removed kokoro:run Add this label to force Kokoro to re-run the tests. labels Aug 16, 2022
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 16, 2022
@hongalex hongalex requested a review from tmdiep August 16, 2022 19:23
@hongalex hongalex enabled auto-merge (squash) August 18, 2022 16:36
@hongalex hongalex merged commit 74da335 into googleapis:main Aug 22, 2022
@hongalex hongalex deleted the pubsub-exactly-once branch August 22, 2022 20:54
codyoss added a commit to codyoss/google-cloud-go that referenced this pull request Aug 24, 2022
In googleapis#6506 changes to internal were made that are not apart of the
pubsub module. The pubsub module was releated before the internal
changes were released resulting in build errors for those that
pulled the latest pubsub version.

Fixes: googleapis#6555
gcf-merge-on-green bot pushed a commit that referenced this pull request Aug 24, 2022
In #6506 changes to internal were made that are not apart of the
pubsub module. The pubsub module was released before the internal
changes were released resulting in build errors for those that
pulled the latest pubsub version.

Fixes: #6555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants