Skip to content

refactor(inkless): improve thread pool lifecycle management#475

Merged
jeqo merged 2 commits intomainfrom
jeqo/refactor-thread-pools
Mar 16, 2026
Merged

refactor(inkless): improve thread pool lifecycle management#475
jeqo merged 2 commits intomainfrom
jeqo/refactor-thread-pools

Conversation

@jeqo
Copy link
Copy Markdown
Contributor

@jeqo jeqo commented Jan 9, 2026

  • FileCommitter: Add missing executorServiceCacheStore shutdown and implement ordered shutdown sequence (reject → cancel cache → await commits → force-stop uploads) to prevent orphaned files in object storage
  • DeleteRecordsInterceptor: Implement Closeable, narrow dependencies from SharedState to ControlPlane + MetadataView, add InklessThreadFactory for consistent thread naming, and register in ReplicaManager.close()
  • FetchOffsetHandler: Use shutdownExecutorServiceQuietly() with 5s timeout, extract constructor for testability
  • Reader, Writer: Add Javadoc documenting thread pool lifecycle

Test plan

  • FileCommitter: graceful close, commit pool timeout, never-terminates, interrupted-during-await
  • DeleteRecordsInterceptor: executor shutdown verified, existing tests updated to close interceptor
  • FetchOffsetHandler: executor shutdown verified

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes thread pool resource leaks in three Inkless storage components by ensuring proper shutdown of all ExecutorService instances during broker lifecycle operations.

Key Changes:

  • Added missing shutdown call for executorServiceCacheStore in FileCommitter, preventing leak of 8 threads per broker shutdown
  • Implemented Closeable interface for DeleteRecordsInterceptor with proper ExecutorService shutdown using 5-second timeout
  • Improved FetchOffsetHandler shutdown from basic shutdown() to shutdownExecutorServiceQuietly() with 5-second timeout

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
storage/inkless/src/main/java/io/aiven/inkless/produce/FileCommitter.java Added missing executorServiceCacheStore.shutdown() call and documentation about thread pool lifecycle
storage/inkless/src/test/java/io/aiven/inkless/produce/FileCommitterTest.java Added verification for executorServiceCacheStore shutdown
storage/inkless/src/main/java/io/aiven/inkless/delete/DeleteRecordsInterceptor.java Implemented Closeable, changed Executor to ExecutorService, added InklessThreadFactory for thread naming, and proper shutdown with timeout
storage/inkless/src/test/java/io/aiven/inkless/delete/DeleteRecordsInterceptorTest.java Added close() calls to all tests and new test verifying shutdown behavior
storage/inkless/src/main/java/io/aiven/inkless/consume/FetchOffsetHandler.java Changed to shutdownExecutorServiceQuietly with timeout, refactored constructor for testability
storage/inkless/src/test/java/io/aiven/inkless/consume/FetchOffsetHandlerTest.java Added test verifying proper executor shutdown with timeout
storage/inkless/src/main/java/io/aiven/inkless/produce/Writer.java Added documentation about thread pool lifecycle management
storage/inkless/src/main/java/io/aiven/inkless/consume/Reader.java Added documentation about thread pool lifecycle management
core/src/main/scala/kafka/server/ReplicaManager.scala Added close() call for inklessDeleteRecordsInterceptor in shutdown sequence

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeqo jeqo force-pushed the jeqo/refactor-thread-pools branch from 2458994 to 89571b9 Compare January 9, 2026 11:39
@jeqo jeqo requested a review from Copilot January 9, 2026 12:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeqo jeqo force-pushed the jeqo/refactor-thread-pools branch from 89571b9 to d6f8803 Compare March 10, 2026 16:13
@jeqo jeqo changed the base branch from jeqo/refactor-shared-state to main March 10, 2026 16:14
@jeqo jeqo requested a review from Copilot March 10, 2026 16:23
@jeqo jeqo changed the title fix(inkless): properly shutdown all thread pools refactor(inkless): improve thread pool lifecycle management Mar 10, 2026

This comment was marked as outdated.

@jeqo jeqo force-pushed the jeqo/refactor-thread-pools branch 3 times, most recently from 43da310 to e871ebb Compare March 10, 2026 16:43
@jeqo jeqo requested a review from Copilot March 10, 2026 17:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- **FileCommitter**: Add missing `executorServiceCacheStore` shutdown and
  implement ordered shutdown sequence (reject → cancel cache → await
  commits → force-stop uploads) to prevent orphaned files in object storage
- **DeleteRecordsInterceptor**: Implement `Closeable`, narrow dependencies
  from `SharedState` to `ControlPlane` + `MetadataView`, add
  `InklessThreadFactory` for consistent thread naming, and register in
  `ReplicaManager.close()`
- **FetchOffsetHandler**: Use `shutdownExecutorServiceQuietly()` with 5s
  timeout, extract constructor for testability
- **Reader, Writer**: Add Javadoc documenting thread pool lifecycle
@jeqo jeqo force-pushed the jeqo/refactor-thread-pools branch from e871ebb to 36a9c65 Compare March 10, 2026 17:20
@jeqo jeqo marked this pull request as ready for review March 10, 2026 21:00
@jeqo jeqo requested review from Mwea and viktorsomogyi March 11, 2026 15:45
viktorsomogyi
viktorsomogyi previously approved these changes Mar 16, 2026
Copy link
Copy Markdown
Contributor

@viktorsomogyi viktorsomogyi left a comment

Choose a reason for hiding this comment

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

I think overall this is good, had one minor comment. I won't merge yet to give @Mwea a chance to add comments if needed.

@jeqo jeqo merged commit 3daf634 into main Mar 16, 2026
6 checks passed
@jeqo jeqo deleted the jeqo/refactor-thread-pools branch March 16, 2026 16:59
AnatolyPopov pushed a commit that referenced this pull request Mar 23, 2026
- **FileCommitter**: Add missing `executorServiceCacheStore` shutdown and
  implement ordered shutdown sequence (reject → cancel cache → await
  commits → force-stop uploads) to prevent orphaned files in object storage
- **DeleteRecordsInterceptor**: Implement `Closeable`, narrow dependencies
  from `SharedState` to `ControlPlane` + `MetadataView`, add
  `InklessThreadFactory` for consistent thread naming, and register in
  `ReplicaManager.close()`
- **FetchOffsetHandler**: Use `shutdownExecutorServiceQuietly()` with 5s
  timeout, extract constructor for testability
- **Reader, Writer**: Add Javadoc documenting thread pool lifecycle

(cherry picked from commit 3daf634)
jeqo added a commit that referenced this pull request Mar 23, 2026
- **FileCommitter**: Add missing `executorServiceCacheStore` shutdown and
  implement ordered shutdown sequence (reject → cancel cache → await
  commits → force-stop uploads) to prevent orphaned files in object storage
- **DeleteRecordsInterceptor**: Implement `Closeable`, narrow dependencies
  from `SharedState` to `ControlPlane` + `MetadataView`, add
  `InklessThreadFactory` for consistent thread naming, and register in
  `ReplicaManager.close()`
- **FetchOffsetHandler**: Use `shutdownExecutorServiceQuietly()` with 5s
  timeout, extract constructor for testability
- **Reader, Writer**: Add Javadoc documenting thread pool lifecycle
jeqo added a commit that referenced this pull request Mar 23, 2026
- **FileCommitter**: Add missing `executorServiceCacheStore` shutdown and
  implement ordered shutdown sequence (reject → cancel cache → await
  commits → force-stop uploads) to prevent orphaned files in object storage
- **DeleteRecordsInterceptor**: Implement `Closeable`, narrow dependencies
  from `SharedState` to `ControlPlane` + `MetadataView`, add
  `InklessThreadFactory` for consistent thread naming, and register in
  `ReplicaManager.close()`
- **FetchOffsetHandler**: Use `shutdownExecutorServiceQuietly()` with 5s
  timeout, extract constructor for testability
- **Reader, Writer**: Add Javadoc documenting thread pool lifecycle

(cherry picked from commit 3daf634)
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