Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

gregfurman
Copy link
Contributor

Motivation

There are still some hanging threads on SQS shutdown due to:

  • Cleanup fixtures deleting SQS queues lifecycle hooks are able to shut them down
  • CloudWatch metric dispatcher does not guard against new submit jobs when executor is shutdown

Changes

  • Shutdown internal SQS queue resource upon deletion.
  • Prevent dispatching new CW jobs when ThreadPoolExecutor object is closed (causing a RuntimeException)

@gregfurman gregfurman added aws:sqs Amazon Simple Queue Service semver: patch Non-breaking changes which can be included in patch releases labels Feb 11, 2025
@gregfurman gregfurman requested a review from dfangl February 11, 2025 15:46
@gregfurman gregfurman self-assigned this Feb 11, 2025
Copy link

github-actions bot commented Feb 11, 2025

LocalStack Community integration with Pro

    2 files  ±    0      2 suites  ±0   1h 15m 7s ⏱️ - 38m 21s
3 010 tests  - 1 087  2 879 ✅  - 902  131 💤  - 185  0 ❌ ±0 
3 012 runs   - 1 087  2 879 ✅  - 902  133 💤  - 185  0 ❌ ±0 

Results for commit 15b4253. ± Comparison against base commit 57aeecb.

This pull request removes 1087 tests.
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_lambda_dynamodb
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_opensearch_crud
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_search_books
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_setup
tests.aws.scenario.kinesis_firehose.test_kinesis_firehose.TestKinesisFirehoseScenario ‑ test_kinesis_firehose_s3
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_destination_sns
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_infra
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_prefill_dynamodb_table
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input0-SUCCEEDED]
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input1-SUCCEEDED]
…

♻️ This comment has been updated with latest results.

@gregfurman gregfurman marked this pull request as ready for review February 11, 2025 17:26
Copy link
Contributor

@bentsku bentsku left a comment

Choose a reason for hiding this comment

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

LGTM! Good catch!

I think we could replace the threading.Event with a boolean in this case, as we don't need to pass the reference around and mutate it. But both works!

Copy link
Contributor

@bentsku bentsku left a comment

Choose a reason for hiding this comment

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

I've just realized we have an issue with the CloudwatchDispatcher: if you call LocalStack reset for SQS, we will shutdown the dispatcher in on_before_stop, but when calling _start_cloudwatch_metrics_reporting in on_before_start we do not reset the flags back, so it will stay in shutdown, as we create the dispatcher in the __init__ method of the provider 🤔 and initialize the event/boolean flag in the __init__ method of the dispatcher too.

Bigger than that, we also don't restart the executor itself. A bit outside of the scope of the PR, but we should probably fix that.

@gregfurman
Copy link
Contributor Author

@bentsku There are a couple issues with the CloudwatchDispatcher imo. We also don't batch requests which means that for each send, receieve, and delete message call we'll send 2, 1, and 1 requests to the CW provider (and hence the gateway) respectively.

@gregfurman gregfurman merged commit 25d4d82 into master Feb 12, 2025
31 checks passed
@gregfurman gregfurman deleted the fix/sqs/cw-shutdown branch February 12, 2025 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:sqs Amazon Simple Queue Service semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants