dsmiley opened a new pull request, #4933:
URL: https://github.com/apache/solr/pull/4933
`ExecutorUtil.isSolrServerThread()` previously became `true` for _any_ task
running on an MDC-aware executor, which could incorrectly treat client work
(either real world or tests) as Solr node identity. This change redefines the
flag to mean “work originating from this Solr node” (startup/request paths and
descendants), and propagates it only via inheritance/submitter context.
- **`ExecutorUtil`: semantic shift from executor-type to work-origin**
- Replaced `ThreadLocal<Boolean>` with `InheritableThreadLocal<Boolean>`.
- In `MDCAwareThreadPoolExecutor.execute(...)`, captured submitter
server-thread state at submission time.
- Applied server-thread flag in worker execution only when submitter was
flagged; otherwise explicitly cleared to prevent inherited-`true` contamination
on reused pool threads.
- Updated javadocs for `isSolrServerThread()` and
`setServerThreadFlag(Boolean)` to document node-origin semantics.
- **Node startup origin marking**
- In `CoreContainerProvider`, wrapped `createCoreContainer(...)` with
`ExecutorUtil.setServerThreadFlag(TRUE)` and restored the prior value in
`finally`.
- This ensures startup-spawned threads inherit server identity while
avoiding flag leakage to the caller thread (notably test bootstrap threads).
- **PKI call-site behavior under new semantics**
- Reviewed existing explicit flagging sites (`SolrServlet`,
`ReplicationHandler`, `PKIAuthenticationPlugin`) and kept behavior aligned.
- Existing explicit scheduling-time flagging in `ReplicationHandler`
remains the intended pattern for independent background entry points.
- **Behavioral coverage added**
- Extended `ExecutorUtilTest` for:
- unflagged submitter ⇒ task not server-thread,
- flagged submitter ⇒ task is server-thread,
- child thread inherits flag,
- reused pool thread does not leak flag across tasks.
```java
final boolean submitterIsSolrServerThread = isSolrServerThread();
super.execute(() -> {
if (submitterIsSolrServerThread) {
isServerPool.set(Boolean.TRUE);
} else {
isServerPool.remove();
}
try {
command.run();
} finally {
isServerPool.remove();
}
});
```
🤖 Written with AI, guided by David Smiley
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]