Repository navigation
Fiddle: release messages on shutdown and delete expired messages in the queue processor - #172
Merged
Merged
Conversation
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.
Description
Two improvements to the message queues, prompted by how the SQL queue behaves in production:
Graceful shutdown
MessageQueue.release_message: hands a claimed message back to be claimed again straight away without using an attempt (SQL and Cosmos keeppostCount; SQS and AQS make it visible again).MessageQueueProcessor.run/run_batchesnow handle SIGTERM/SIGINT (andrequest_shutdown()): the message being processed finishes, claimed messages not yet started are released, and the idle sleep stops immediately. A second signal falls back to the default handler.Housekeeping
MessageQueue.delete_expired_messages:SqlMessageQueuedeletessucceeded/deduplicatedrows older thanretentionSeconds; other queues remove messages on completion and return 0.deleteExpiredMessagesIntervalSeconds(default 600), logging rather than raising on failure.SqlMessageQueue.get_message_countno longer deletes rows;shouldSkipRemovingNonRetainedis removed (breaking).Also adds
shouldProcessInParalleltorun_batchesso consumers can try processing a claimed batch concurrently.Tests: release on every backend (including after a lost lease), shutdown finishing the current message and releasing the rest, a real SIGTERM stopping an idle run, a cancelled message being released without an attempt, and the processor deleting expired rows. 141 queue/lock/database tests pass locally against sqlite, Postgres, Cosmos, ElasticMQ and Azurite.
Note:
make type-checkonmaincurrently reports 35Unpackerrors incore/store/*; they are identical without this change.Checklist: