You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "maytasm (via GitHub)" <gi...@apache.org> on 2024/06/15 03:35:22 UTC
[PR] Fix task context fails with non string property value (druid)
maytasm opened a new pull request, #16612:
URL: https://github.com/apache/druid/pull/16612
Fix task context fails with non string property value
### Description
This is a regression caused by https://github.com/apache/druid/pull/14239
The above PR introduces a new method `addSystemProperty` with String type in the method definition for the property value. (Previously, we were using `StringUtils.format` which takes in Object as argument). The problem is that `task.getContextValue(propName)` has a return type which is a generic type parameter ContextValueType. This means the method can return a value of any type specified at the time of invocation. When the value of the context property is not a String, Java is still trying to call the `addSystemProperty` with String type causing the task to fail.
i.e. if we have something like
```
"context": {
"druid.indexer.fork.property.druid.processing.numThreads": 4
}
```
we'll get the error:
```
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at org.apache.druid.indexing.overlord.ForkingTaskRunner$1.call(ForkingTaskRunner.java:319) [druid-indexing-service-31.0.0-SNAPSHOT.jar:31.0.0-SNAPSHOT]
at org.apache.druid.indexing.overlord.ForkingTaskRunner$1.call(ForkingTaskRunner.java:171) [druid-indexing-service-31.0.0-SNAPSHOT.jar:31.0.0-SNAPSHOT]
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131) [guava-32.0.1-jre.jar:?]
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:75) [guava-32.0.1-jre.jar:?]
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82) [guava-32.0.1-jre.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_322]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_322]
at java.lang.Thread.run(Thread.java:750) [?:1.8.0_322]
```
This PR fix the issue by casting the return value from `task.getContextValue(propName)` to Object and then use `addSystemProperty` with Object type for the value parameter.
This PR has:
- [x] been self-reviewed.
- [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
- [ ] added integration tests.
- [x] been tested in a test Druid cluster.
--
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 task context fails with non string property value (druid)
Posted by "maytasm (via GitHub)" <gi...@apache.org>.
maytasm commented on PR #16612:
URL: https://github.com/apache/druid/pull/16612#issuecomment-2169138172
@kfaraz Updated the PR with the approach used in [#16281](https://github.com/apache/druid/pull/16281/files) and clean up some stuff. Can you please review? Thanks!
--
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 task context fails with non string property value (druid)
Posted by "maytasm (via GitHub)" <gi...@apache.org>.
maytasm closed pull request #16612: Fix task context fails with non string property value
URL: https://github.com/apache/druid/pull/16612
--
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 task context fails with non string property value (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz merged PR #16612:
URL: https://github.com/apache/druid/pull/16612
--
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 task context fails with non string property value (druid)
Posted by "maytasm (via GitHub)" <gi...@apache.org>.
maytasm commented on PR #16612:
URL: https://github.com/apache/druid/pull/16612#issuecomment-2169137033
@kfaraz Oh. I misread your comment. Will update this PR to use the same approach used in https://github.com/apache/druid/pull/16281
--
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 task context fails with non string property value (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on PR #16612:
URL: https://github.com/apache/druid/pull/16612#issuecomment-2169083408
@maytasm , this PR https://github.com/apache/druid/pull/16281/files also fixes the same issue.
Maybe we can just merge that existing PR instead?
It seems to have been pending because of coverage issues.
--
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 task context fails with non string property value (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #16612:
URL: https://github.com/apache/druid/pull/16612#discussion_r1640683404
##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/ForkingTaskRunner.java:
##########
@@ -924,6 +924,11 @@ public CommandListBuilder addSystemProperty(String property, boolean value)
return addSystemProperty(property, String.valueOf(value));
}
+ public CommandListBuilder addSystemProperty(String property, Object value)
Review Comment:
This new method feels unnecessary.
Maybe we can use the approach used in #16281 instead.
Since the original author has not responded on that PR, we can proceed with this one.
--
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 task context fails with non string property value (druid)
Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #16612:
URL: https://github.com/apache/druid/pull/16612#discussion_r1640741270
##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/ForkingTaskRunner.java:
##########
@@ -924,6 +924,11 @@
return addSystemProperty(property, String.valueOf(value));
}
+ public CommandListBuilder addSystemProperty(String property, Object value)
Review Comment:
## Confusing overloading of methods
Method CommandListBuilder.addSystemProperty(..) could be confused with overloaded method [addSystemProperty](1), since dispatch depends on static types.
[Show more details](https://github.com/apache/druid/security/code-scanning/7458)
--
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 task context fails with non string property value (druid)
Posted by "maytasm (via GitHub)" <gi...@apache.org>.
maytasm commented on PR #16612:
URL: https://github.com/apache/druid/pull/16612#issuecomment-2169120180
> @maytasm , this PR https://github.com/apache/druid/pull/16281/files also fixes the same issue. ~Maybe we can just merge that existing PR instead?~ The original author has not responded on that PR, so we can proceed with this one.
SGTM. Closing
--
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 task context fails with non string property value (druid)
Posted by "maytasm (via GitHub)" <gi...@apache.org>.
maytasm commented on code in PR #16612:
URL: https://github.com/apache/druid/pull/16612#discussion_r1640769708
##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/ForkingTaskRunner.java:
##########
@@ -924,6 +924,11 @@ public CommandListBuilder addSystemProperty(String property, boolean value)
return addSystemProperty(property, String.valueOf(value));
}
+ public CommandListBuilder addSystemProperty(String property, Object value)
Review Comment:
Done.
--
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