Fix assertion error for messages_on_hold._activate_ordering_keys #913
Labels
api: pubsub
Issues related to the googleapis/python-pubsub API.
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
It is possible to call activate_ordering_keys with keys which are not present in messages_on_hold._pending_ordered_messages. This can happen if:
A message (or messages) lease exceeds max_lease_duration, it is dropped from maintain_leases
We call drop in the dispatcher
python-pubsub/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py
Line 295 in 9ffb8d6
If there are no messages remaining in messages_on_hold._pending_ordered_messages, therefore the pending_ordered_messages queue for the ordering key is removed:
https://github.com/googleapis/python-pubsub/blob/main/google/cloud/pubsub_v1/subscriber/_protocol/messages_on_hold.py#L154
The message is acked from the user callback, the ack completes and drop is called in the dispatcher:
python-pubsub/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py
Line 247 in f3bf21d
We call _activate_ordering_keys with a key that does not exist in messages_on_hold._pending_ordered_messages:
https://github.com/googleapis/python-pubsub/blob/main/google/cloud/pubsub_v1/subscriber/_protocol/messages_on_hold.py#L122
Reproduction:
Results:
The text was updated successfully, but these errors were encountered: