aws / aws/aws-activejob-sqs-ruby
Delay shutdown until the last sqs_message has been posted to the executor.
- Dominant language
- Ruby
- Stars
- 37
- Forks
- 10
- Avg merge
- 18h 57m
- Merged PRs (30d)
- 1
Description
### Describe the feature
Hello, thanks for developing a great gem.
I have a request regarding the behaviour when SIGTERM fires.
My understanding is that the flow is currently as follows.
1. receive a SIGTERM
2. execute `raise Interrupt` with `trap`.
3. executor terminates as soon as the execution of the job in the queue is completed (until the timeout comes).
If `@executor.execute(sqs_message)` is executed on receipt of a SIGTERM, but there is a sqs_message that has not yet entered the queue because, for example, the max_queue has been reached, this message is not processed and is terminated.
We want the processing of this sqs_message to also continue until the timeout arrives.
Could you please consider changing the behaviour or adding this as an option?
### Use Case
We use a lot of Fargate spots and would like to increase the number of jobs that can be processed without waiting for a visibility timeout as much as possible from a performance perspective.
### Proposed Solution
Modified behaviour of Signal.trap.
1. set an instance variable to indicate that a SIGTERM signal has been received
2. `raise Interrupt` after executing execute_messages with `_poll`.
If you want to take into account the risk that the timeout setting will not function properly:
1. add another timeout during the waiting period of the last execute_messages
### Other Information
_No response_
### Acknowledgements
- [x] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### SDK version used
1.0.1
### Environment details (OS name and version, etc.)
Linux
Contributor guide
Research direction
Start by tracing Signal.trap through execute_messages, _poll, and @executor.execute(sqs_message) to understand when shutdown interrupts polling and queued work. Compare the current behavior with the proposed delayed interrupt, including the timeout while the final messages are submitted; done means messages received before shutdown are submitted and allowed to run without breaking timeout handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, ruby
- Domain
- backend, distributed-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100