Skip to content

MLE-26865, MLE-26867: Fixes for issues identified by Polaris#581

Merged
SiddharthMaheshB merged 2 commits intomarklogic:developfrom
SiddharthMaheshB:develop
Apr 2, 2026
Merged

MLE-26865, MLE-26867: Fixes for issues identified by Polaris#581
SiddharthMaheshB merged 2 commits intomarklogic:developfrom
SiddharthMaheshB:develop

Conversation

@SiddharthMaheshB
Copy link
Copy Markdown

This PR contains fixes for two issues identified through Polaris scans:

MLE-26865: Using pool.wait()/notify() makes the code vulnerable to spurious wakeups. This was fixed by replacing it with CountDownLatch instead.
MLE-24515: Potential divide by zero issue where getActiveTaskCounts() returns 0.

I ran the unit test and 06mlcp, both passing with no failures other than expected ones.

SiddharthMaheshB and others added 2 commits March 31, 2026 22:25
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ss spurious wakeup vulnerability

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

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 PR addresses two Polaris findings in the local-threading/autoscaling path: replacing wait()/notify() synchronization used when starting MultithreadedMapper runners with a CountDownLatch, and guarding an autoscaling path that could divide by zero when there are no active tasks.

Changes:

  • Replace pool.wait()/notify() coordination during LocalMapTask submission with a per-task CountDownLatch.
  • Add a guard in ThreadManager.ThreadPoller to exit early when getActiveTaskCounts() returns 0.
  • Wire latch propagation from LocalMapTask into MultithreadedMapper so runner creation signals the submitter thread.

Reviewed changes

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

File Description
src/main/java/com/marklogic/contentpump/ThreadManager.java Switches task-submission coordination to CountDownLatch.await() and adds an early-return guard for activeTaskCounts == 0 in the poller.
src/main/java/com/marklogic/contentpump/MultithreadedMapper.java Adds latch field/setter and counts down after creating runners (replacing threadPool.notify()).
src/main/java/com/marklogic/contentpump/LocalJobRunner.java Adds a per-task latch, exposes it, passes it into MultithreadedMapper, and counts it down on task failure.

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

Comment thread src/main/java/com/marklogic/contentpump/ThreadManager.java
Copy link
Copy Markdown
Contributor

@NeoSaber NeoSaber left a comment

Choose a reason for hiding this comment

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

The changes in this PR look fine to me, so I am approving it.

However, I am concerned about the issue Copilot noticed in ThreadManager. The fix it suggested looks wrong to me, but its analysis of the problem it found with the way randomIndexes.get(i) gets used does seem to be accurate based on what I am seeing in the code. It's a little hard to believe an issue like that isn't crashing frequently, so something else might be going on. I think there needs to be a new bug ticket made for that issue so it can be investigated more deeply by someone and fixed if it is really a problem.

@SiddharthMaheshB
Copy link
Copy Markdown
Author

I have created a bug for it: https://progresssoftware.atlassian.net/browse/MLE-28260, will work on it later.

@SiddharthMaheshB SiddharthMaheshB merged commit 9b3c171 into marklogic:develop Apr 2, 2026
8 checks passed
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