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): publish-side changes for ordering keys #9929

Closed
wants to merge 18 commits into from

Conversation

pradn
Copy link
Contributor

@pradn pradn commented Dec 6, 2019

  • Create a new concept: sequencers. A sequencer orders messages published by the publishing client. Messages with ordering keys use the OrderedSequencer. Those without ordering keys use the UnorderedSequencer, which behaves just like before.
  • The OrderedSequencer is paused when it encounters a permanent error. It must be unpaused manually by the user calling client.resumePublish() to continue sending messages for that ordering key. This is done to prevent out-of-order sending.
  • Move the commit thread to the publisher client. This one thread commits batches in all sequencers. Before, each batch had its own commit thread.
  • Clean up ordering-key enabled sequencers after all messages are sent. (If paused, the OrderedSequencer is not cleaned-up.)
  • Added tests for all the changes.

Implements half of #9928

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 6, 2019
@pradn pradn changed the title Publish-side changes for ordering keys feat(pubsub): Publish-side changes for ordering keys Dec 6, 2019
@pradn pradn changed the title feat(pubsub): Publish-side changes for ordering keys feat(pubsub): publish-side changes for ordering keys Dec 9, 2019
Copy link
Contributor

@plamut plamut left a comment

Choose a reason for hiding this comment

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

In general the design looks good and is understandable IMO. I did not try using the new feature, focused only on the code for now.

There are quite a few suggestions/comments, but the PR itself is also quite sizable. Some of them are minor/non-essential, but it's my last review cycle of the year, thus a bit biased towards verbosity. :)

On top of everything, this is a non-trivial feature that would highly benefit from at least a basic system test or two (if the ordering keys feature is not yet enabled on the test project, we must enable them first).

pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py Outdated Show resolved Hide resolved
pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py Outdated Show resolved Hide resolved
pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py Outdated Show resolved Hide resolved
pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py Outdated Show resolved Hide resolved
pubsub/google/cloud/pubsub_v1/publisher/client.py Outdated Show resolved Hide resolved
pubsub/google/cloud/pubsub_v1/publisher/client.py Outdated Show resolved Hide resolved
pubsub/google/cloud/pubsub_v1/publisher/client.py Outdated Show resolved Hide resolved
pubsub/google/cloud/pubsub_v1/publisher/client.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@pradn pradn left a comment

Choose a reason for hiding this comment

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

Thanks for the review. A system test is forthcoming, after the subscriber side changes.

Copy link

@kamalaboulhosn kamalaboulhosn left a comment

Choose a reason for hiding this comment

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

Generally looks good!

Copy link
Contributor

@plamut plamut left a comment

Choose a reason for hiding this comment

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

The updates look good, thanks!

There are still a few comments from the original review that have not been addressed yet (most of those that were hidden by default). Please just check them out, or mark as resolved if you think they aren't relevant (enough).

Copy link
Contributor

@plamut plamut left a comment

Choose a reason for hiding this comment

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

Apart for a minor docstring thingy, it now looks good IMO.

Disclaimer - did not run the code, we need the subscriber side for ordering keys as well (the same reason why there are no system tests yet).

pubsub/tests/unit/pubsub_v1/publisher/batch/test_thread.py Outdated Show resolved Hide resolved
@plamut plamut self-requested a review December 20, 2019 22:50
@plamut
Copy link
Contributor

plamut commented Jan 16, 2020

What's the status of this? I see that error handling was changed in one particular case, and that a deadlock was fixed.

@pradn Would you mind elaborating a bit on the latter? Looking at the state machine and the commit message, it appears to be something with publishing in a STOPPED state, and a new state FINISHED had to be introduced? Or why the deadlock could occur? Thanks!

@plamut plamut added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jan 16, 2020
@plamut
Copy link
Contributor

plamut commented Jan 16, 2020

As per offline discussion, we want to wait for the subscriber side of this, as well as for a fix for a performance regression that was discovered.

@plamut plamut added the api: pubsub Issues related to the Pub/Sub API. label Jan 31, 2020
@plamut
Copy link
Contributor

plamut commented Feb 10, 2020

Superseded by googleapis/python-pubsub#26

@plamut plamut closed this Feb 10, 2020
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. cla: yes This human has signed the Contributor License Agreement. do not merge Indicates a pull request not ready for merge, due to either quality or timing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants