You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "Shekharrajak (via GitHub)" <gi...@apache.org> on 2026/05/21 09:26:38 UTC
[PR] Fix OrcInputFormat concurrent FileSystem init race condition (#19491) (druid)
Shekharrajak opened a new pull request, #19497:
URL: https://github.com/apache/druid/pull/19497
Fixes https://github.com/apache/druid/issues/19491.
### Description
OrcInputFormat.initialize() — which swaps Thread.currentThread().setContextClassLoader() and calls FileSystem.get(conf) — was invoked on every createReader() call. When a ParallelIndexTask runs multiple ORC subtasks concurrently in the same JVM (as in embedded tests)
#### Fixed the bug
Added an AtomicBoolean fileSystemInitialized guard
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] fix: OrcInputFormat concurrent FileSystem init race condition (#19491) (druid)
Posted by "Shekharrajak (via GitHub)" <gi...@apache.org>.
Shekharrajak commented on PR #19497:
URL: https://github.com/apache/druid/pull/19497#issuecomment-4536044930
Hi @FrankChen021 @jtuglu1 , let's merge this changes to unblock the PR https://github.com/apache/druid/pull/19266
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] fix: OrcInputFormat concurrent FileSystem init race condition (#19491) (druid)
Posted by "Shekharrajak (via GitHub)" <gi...@apache.org>.
Shekharrajak commented on PR #19497:
URL: https://github.com/apache/druid/pull/19497#issuecomment-4522001517
@FrankChen021 CI checks looking good now. Please have a look.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] fix: OrcInputFormat concurrent FileSystem init race condition (#19491) (druid)
Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 merged PR #19497:
URL: https://github.com/apache/druid/pull/19497
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] fix: OrcInputFormat concurrent FileSystem init race condition (#19491) (druid)
Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 commented on code in PR #19497:
URL: https://github.com/apache/druid/pull/19497#discussion_r3281507046
##########
extensions-core/orc-extensions/src/main/java/org/apache/druid/data/input/orc/OrcInputFormat.java:
##########
@@ -55,14 +57,15 @@ public OrcInputFormat(
this.conf = conf;
}
- private void initialize(Configuration conf)
+ // Ensure FileSystem class-level initialization happens with the correct classloader (see #1714).
+ // Called once on first createReader() via AtomicBoolean guard to prevent a race when multiple
+ // subtasks concurrently swap Thread.currentThread().setContextClassLoader() (see #19491).
+ private void ensureFileSystemInitialized()
{
- //Initializing seperately since during eager initialization, resolving
- //namenode hostname throws an error if nodes are ephemeral
-
- // Ensure that FileSystem class level initialization happens with correct CL
- // See https://github.com/apache/druid/issues/1714
- ClassLoader currCtxCl = Thread.currentThread().getContextClassLoader();
+ if (!fileSystemInitialized.compareAndSet(false, true)) {
Review Comment:
[P2] Reset initialization guard when FileSystem init fails
`compareAndSet(false, true)` marks the format initialized before `FileSystem.get(conf)` has actually succeeded. If that call throws an `IOException`, the flag remains true and every later `createReader` on the same `OrcInputFormat` skips the classloader-protected Hadoop FileSystem initialization instead of retrying, which is a regression from the previous per-reader behavior. Set the flag only after `FileSystem.get(conf)` succeeds, or reset it in the catch path before rethrowing.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] fix: OrcInputFormat concurrent FileSystem init race condition (#19491) (druid)
Posted by "Shekharrajak (via GitHub)" <gi...@apache.org>.
Shekharrajak commented on code in PR #19497:
URL: https://github.com/apache/druid/pull/19497#discussion_r3283245141
##########
extensions-core/orc-extensions/src/main/java/org/apache/druid/data/input/orc/OrcInputFormat.java:
##########
@@ -55,14 +57,15 @@ public OrcInputFormat(
this.conf = conf;
}
- private void initialize(Configuration conf)
+ // Ensure FileSystem class-level initialization happens with the correct classloader (see #1714).
+ // Called once on first createReader() via AtomicBoolean guard to prevent a race when multiple
+ // subtasks concurrently swap Thread.currentThread().setContextClassLoader() (see #19491).
+ private void ensureFileSystemInitialized()
{
- //Initializing seperately since during eager initialization, resolving
- //namenode hostname throws an error if nodes are ephemeral
-
- // Ensure that FileSystem class level initialization happens with correct CL
- // See https://github.com/apache/druid/issues/1714
- ClassLoader currCtxCl = Thread.currentThread().getContextClassLoader();
+ if (!fileSystemInitialized.compareAndSet(false, true)) {
Review Comment:
Thanks for checking reseting https://github.com/apache/druid/pull/19497/changes/1b300994c0eda1275169dc878461d8974d13d260#diff-8f129e69b5d986ba1793e9ec079452a0722b8012b8521a03f77716e94f500153R75
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org