Skip to content

Using jthread to solve .detach() problem on graceful shutdown#153

Open
hemant-endee wants to merge 1 commit intomasterfrom
hemant/backup_thread_detach_correction
Open

Using jthread to solve .detach() problem on graceful shutdown#153
hemant-endee wants to merge 1 commit intomasterfrom
hemant/backup_thread_detach_correction

Conversation

@hemant-endee
Copy link
Copy Markdown
Collaborator

PR Summary:

Problem: Backup thread used .detach() — on graceful shutdown, ~IndexManager destroyed members while the detached thread was still using them (use-after-free)

Solution :

  • Using std::jthread (C++20). Thread handle stored in BackupStore, joined in destructor before members are destroyed
  • jthread's built-in stop_token is passed into createBackupTar and checked per-file in the tar loop.
  • On SIGTERM, the thread aborts within one file iteration instead of blocking shutdown until the entire tar completes

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.

1 participant