Skip to content

Iterate on DLM Transition service#145081

Merged
lukewhiting merged 8 commits intoelastic:mainfrom
lukewhiting:dlm-executor-followup
Mar 30, 2026
Merged

Iterate on DLM Transition service#145081
lukewhiting merged 8 commits intoelastic:mainfrom
lukewhiting:dlm-executor-followup

Conversation

@lukewhiting
Copy link
Copy Markdown
Contributor

This makes a few improvements to the DLM transition service:

  • Add a queue to the executor to allow more indices than worker threads to be submitted for conversion, preventing wasted time between threads becoming available and the next loop through the marked indices
  • Switches to using the ESExecutors daemon thread factory, removing the need to declare thread management capabilities in this plugin
  • Wraps the executor's thread factory so the index name is appended to the thread name
  • Tracks running transitions in a map (Currently just a bool for is running or is queued) but could later be expanded to be an enum or alike to track more detailed progress / state.
  • Fixes relevant tests in both the executor and service to account for the new queue

Add queuing to executor, improve tests and remove thread capabilities
@lukewhiting
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

This PR refactors the DLM frozen transition executor to implement bounded-queue task scheduling. It replaces set-based running-state tracking with a concurrent map that tracks both queued and active transitions by index name, adds a configurable maxQueueSize setting (default 500), and configures the thread pool with a bounded queue matching that size. Capacity checks now account for both active concurrency and queue depth. The executor constructor signature changes to accept maxQueueSize, and transition tracking methods are renamed from isTransitionRunning to transitionSubmitted. The entitlement policy is simplified by removing an unnecessary permission entry.

Possibly related PRs

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
x-pack/plugin/dlm-frozen-transition/src/main/java/org/elasticsearch/xpack/dlm/frozen/DlmFrozenTransitionExecutor.java (1)

50-56: Thread name customization won't work as intended.

The r instanceof DlmFrozenTransitionRunnable check will always be false—by the time the thread factory receives r, it's wrapped in executor infrastructure (e.g., FutureTask), not the original task.

Not a merge blocker—functionality is correct, just thread names won't include the index.

Alternative: Pass index name via ThreadLocal or remove the dead code

If index-specific thread names are important, consider a ThreadLocal<String> set in wrapRunnable() and read in the thread factory. Otherwise, this block can be removed since it never executes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@x-pack/plugin/dlm-frozen-transition/src/main/java/org/elasticsearch/xpack/dlm/frozen/DlmFrozenTransitionExecutor.java`
around lines 50 - 56, The thread-name customization block inside the
EsExecutors.newFixed factory doesn't work because the runnable handed to the
thread factory is wrapped (e.g., FutureTask), so the `r instanceof
DlmFrozenTransitionRunnable` check never matches; either remove that dead branch
or implement the suggested ThreadLocal approach: set a ThreadLocal<String>
(e.g., in DlmFrozenTransitionExecutor.wrapRunnable or where
DlmFrozenTransitionRunnable is wrapped) with dftr.getIndexName() before wrapping
and clear it after, then read that ThreadLocal in the thread factory used by
EsExecutors.newFixed (EXECUTOR_NAME) to append the index to thread.getName();
reference DlmFrozenTransitionRunnable, wrapRunnable(),
EsExecutors.newFixed/EXECUTOR_NAME and the thread factory to locate the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@x-pack/plugin/dlm-frozen-transition/src/main/java/org/elasticsearch/xpack/dlm/frozen/DlmFrozenTransitionExecutor.java`:
- Around line 50-56: The thread-name customization block inside the
EsExecutors.newFixed factory doesn't work because the runnable handed to the
thread factory is wrapped (e.g., FutureTask), so the `r instanceof
DlmFrozenTransitionRunnable` check never matches; either remove that dead branch
or implement the suggested ThreadLocal approach: set a ThreadLocal<String>
(e.g., in DlmFrozenTransitionExecutor.wrapRunnable or where
DlmFrozenTransitionRunnable is wrapped) with dftr.getIndexName() before wrapping
and clear it after, then read that ThreadLocal in the thread factory used by
EsExecutors.newFixed (EXECUTOR_NAME) to append the index to thread.getName();
reference DlmFrozenTransitionRunnable, wrapRunnable(),
EsExecutors.newFixed/EXECUTOR_NAME and the thread factory to locate the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: ef209135-e37f-45a3-b4ce-0ba669b69dcd

📥 Commits

Reviewing files that changed from the base of the PR and between a7e2068 and 953b929.

📒 Files selected for processing (6)
  • x-pack/plugin/dlm-frozen-transition/src/main/java/org/elasticsearch/xpack/dlm/frozen/DlmFrozenTransitionExecutor.java
  • x-pack/plugin/dlm-frozen-transition/src/main/java/org/elasticsearch/xpack/dlm/frozen/DlmFrozenTransitionPlugin.java
  • x-pack/plugin/dlm-frozen-transition/src/main/java/org/elasticsearch/xpack/dlm/frozen/DlmFrozenTransitionService.java
  • x-pack/plugin/dlm-frozen-transition/src/main/plugin-metadata/entitlement-policy.yaml
  • x-pack/plugin/dlm-frozen-transition/src/test/java/org/elasticsearch/xpack/dlm/frozen/DlmFrozenTransitionExecutorTests.java
  • x-pack/plugin/dlm-frozen-transition/src/test/java/org/elasticsearch/xpack/dlm/frozen/DlmFrozenTransitionServiceTests.java
💤 Files with no reviewable changes (1)
  • x-pack/plugin/dlm-frozen-transition/src/main/plugin-metadata/entitlement-policy.yaml

Copy link
Copy Markdown
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

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

LGTM, I left some minor comments, but nothing blocking. Thanks for working on this Luke!

@lukewhiting lukewhiting enabled auto-merge (squash) March 30, 2026 13:58
Copy link
Copy Markdown
Contributor

@seanzatzdev seanzatzdev left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@lukewhiting lukewhiting merged commit 4f34d9a into elastic:main Mar 30, 2026
35 checks passed
mouhc1ne pushed a commit to shmuelhanoch/elasticsearch that referenced this pull request Mar 31, 2026
* Iterate on DLM Transition service

Add queuing to executor, improve tests and remove thread capabilities

* Use named wrapper class for runnable to ensure thread name instanceof matches

* CheckStyle fix

* PR Changes
@lukewhiting lukewhiting deleted the dlm-executor-followup branch March 31, 2026 07:47
ncordon pushed a commit to ncordon/elasticsearch that referenced this pull request Apr 1, 2026
* Iterate on DLM Transition service

Add queuing to executor, improve tests and remove thread capabilities

* Use named wrapper class for runnable to ensure thread name instanceof matches

* CheckStyle fix

* PR Changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants