Skip to content

Conversation

@iuwqyir
Copy link
Contributor

@iuwqyir iuwqyir commented Feb 5, 2025

TL;DR

Added graceful shutdown support to all orchestrator components using context cancellation.

What changed?

  • Modified all orchestrator components (ChainTracker, Committer, FailureRecoverer, Poller, ReorgHandler) to accept a context parameter
  • Added signal handling for SIGTERM and SIGINT in the main orchestrator
  • Implemented proper cleanup with defer ticker.Stop() in all components
  • Added new shutdown method to the orchestrator
  • Added test coverage for graceful shutdown scenarios

How to test?

  1. Run the application
  2. Send a SIGTERM signal (kill -TERM <pid>)
  3. Verify that all components log their shutdown messages
  4. Confirm that the application exits cleanly without hanging
  5. Run the test suite to verify the new shutdown behavior tests pass

Why make this change?

This change ensures proper resource cleanup and graceful shutdown when the application needs to stop, preventing resource leaks and allowing for clean container orchestration. It's particularly important for cloud deployments where proper shutdown handling is crucial for container lifecycle management.

Copy link
Contributor Author

iuwqyir commented Feb 5, 2025

@iuwqyir iuwqyir changed the title handle sigterm Handle sigterm Feb 5, 2025
@iuwqyir iuwqyir requested a review from a team February 5, 2025 01:22
@iuwqyir iuwqyir marked this pull request as ready for review February 5, 2025 01:22
@iuwqyir iuwqyir force-pushed the 02-05-handle_sigterm branch from cca13d7 to 709e2ec Compare February 5, 2025 14:37
@iuwqyir iuwqyir changed the base branch from 02-04-use_versionedcollapsingmergetree_and_insert_based_deletes to 02-05-chain_based_table_name_and_default_columns_configuration February 5, 2025 14:37
@iuwqyir iuwqyir force-pushed the 02-05-handle_sigterm branch from 709e2ec to 5ca2e8c Compare February 6, 2025 10:41
@iuwqyir iuwqyir force-pushed the 02-05-chain_based_table_name_and_default_columns_configuration branch from cdb704c to d544409 Compare February 6, 2025 11:59
@iuwqyir iuwqyir force-pushed the 02-05-handle_sigterm branch from 5ca2e8c to a851003 Compare February 6, 2025 11:59
@iuwqyir iuwqyir force-pushed the 02-05-chain_based_table_name_and_default_columns_configuration branch from d544409 to f38472e Compare February 6, 2025 12:17
@iuwqyir iuwqyir force-pushed the 02-05-handle_sigterm branch from a851003 to 91c6a6f Compare February 6, 2025 12:17
@iuwqyir iuwqyir force-pushed the 02-05-chain_based_table_name_and_default_columns_configuration branch from f38472e to 52fa30c Compare February 6, 2025 12:34
@iuwqyir iuwqyir force-pushed the 02-05-handle_sigterm branch from 91c6a6f to a4e99ae Compare February 6, 2025 12:34
Base automatically changed from 02-05-chain_based_table_name_and_default_columns_configuration to 02-04-use_versionedcollapsingmergetree_and_insert_based_deletes February 6, 2025 14:13
Base automatically changed from 02-04-use_versionedcollapsingmergetree_and_insert_based_deletes to main February 6, 2025 14:14
@iuwqyir iuwqyir merged commit 0bbbf18 into main Feb 6, 2025
5 checks passed
@iuwqyir iuwqyir deleted the 02-05-handle_sigterm branch February 6, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants