New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STORM-3727 handle long values for SUPERVISOR_SLOTS_PORTS #3365
Conversation
new ArrayList<>()); | ||
for (Number port : ports) { | ||
slotsPorts.add(port.intValue()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would may involve rounding or truncation which isn't really what we wanted.
A port by definition is no larger than 65535. So logically it will be Integers.
There is an Integer check here
storm/storm-server/src/main/java/org/apache/storm/DaemonConfig.java
Lines 742 to 743 in 6e37072
@IsListEntryCustom(entryValidatorClasses = { ConfigValidation.IntegerValidator.class, ConfigValidation.PositiveNumberValidator.class }) | |
public static final String SUPERVISOR_SLOTS_PORTS = "supervisor.slots.ports"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is similar to how the code used to be (see https://github.com/apache/storm/blame/69e69d40d5c700465b49f4c23312f974fb2ca1f6/storm-server/src/main/java/org/apache/storm/daemon/supervisor/ReadClusterState.java#L101-L103) before this change: https://github.com/apache/storm/pull/3267/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we reproduce this?
I changed the port to be a value larger than Integer.MAX_VALUE, the supervisor fails to start
2020-12-21 22:50:47.009 o.a.s.v.ConfigValidation main [INFO] Will use [class org.apache.storm.DaemonConfig, class org.apache.storm.Config] for validation
2020-12-21 22:50:47.250 o.a.s.u.Utils main [ERROR] Received error in thread main.. terminating server...
java.lang.Error: java.lang.IllegalArgumentException: Field SUPERVISOR_SLOTS_PORTS list entry must be an Integer within type range.
at org.apache.storm.utils.Utils.handleUncaughtException(Utils.java:664) ~[storm-client-2.3.0.y.jar:2.3.0-SNAPSHOT]
at org.apache.storm.utils.Utils.handleUncaughtException(Utils.java:668) ~[storm-client-2.3.0.y.jar:2.3.0-SNAPSHOT]
at org.apache.storm.utils.Utils.lambda$createDefaultUncaughtExceptionHandler$2(Utils.java:1048) ~[storm-client-2.3.0.y.jar:2.3.0-SNAPSHOT]
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1057) [?:1.8.0_262]
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1052) [?:1.8.0_262]
at java.lang.Thread.dispatchUncaughtException(Thread.java:1959) [?:1.8.0_262]
Caused by: java.lang.IllegalArgumentException: Field SUPERVISOR_SLOTS_PORTS list entry must be an Integer within type range.
at org.apache.storm.validation.ConfigValidation$IntegerValidator.validateInteger(ConfigValidation.java:415) ~[storm-client-2.3.0.y.jar:2.3.0-SNAPSHOT]
at org.apache.storm.validation.ConfigValidation$IntegerValidator.validateField(ConfigValidation.java:401) ~[storm-client-2.3.0.y.jar:2.3.0-SNAPSHOT]
at org.apache.storm.validation.ConfigValidation$ListEntryCustomValidator.validateField(ConfigValidation.java:588) ~[storm-client-2.3.0.y.jar:2.3.0-SNAPSHOT]
at org.apache.storm.validation.ConfigValidation$ListEntryCustomValidator.validateField(ConfigValidation.java:602) ~[storm-client-2.3.0.y.jar:2.3.0-SNAPSHOT]
at org.apache.storm.validation.ConfigValidation.validateField(ConfigValidation.java:167) ~[storm-client-2.3.0.y.jar:2.3.0-SNAPSHOT]
at org.apache.storm.validation.ConfigValidation.validateFields(ConfigValidation.java:215) ~[storm-client-2.3.0.y.jar:2.3.0-SNAPSHOT]
at org.apache.storm.validation.ConfigValidation.validateFields(ConfigValidation.java:189) ~[storm-client-2.3.0.y.jar:2.3.0-SNAPSHOT]
at org.apache.storm.utils.ConfigUtils.readStormConfigImpl(ConfigUtils.java:440) ~[storm-client-2.3.0.y.jar:2.3.0-SNAPSHOT]
at org.apache.storm.utils.ConfigUtils.readStormConfig(ConfigUtils.java:166) ~[storm-client-2.3.0.y.jar:2.3.0-SNAPSHOT]
at org.apache.storm.daemon.supervisor.Supervisor.<init>(Supervisor.java:126) ~[storm-server-2.3.0.y.jar:2.3.0-SNAPSHOT]
at org.apache.storm.daemon.supervisor.Supervisor.main(Supervisor.java:200) ~[storm-server-2.3.0.y.jar:2.3.0-SNAPSHOT]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this change:
./bin/storm supervisor -c supervisor.slots.ports="[6700]"
2020-12-28 14:06:38.860 o.a.s.d.s.Supervisor main [ERROR] Failed to start supervisor
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
at org.apache.storm.daemon.supervisor.ReadClusterState.(ReadClusterState.java:101) ~[storm-server-2.3.0-SNAPSHOT.jar:2.3.0-SNAPSHOT]
at org.apache.storm.daemon.supervisor.Supervisor.launch(Supervisor.java:310) ~[storm-server-2.3.0-SNAPSHOT.jar:2.3.0-SNAPSHOT]
at org.apache.storm.daemon.supervisor.Supervisor.launchDaemon(Supervisor.java:340) [storm-server-2.3.0-SNAPSHOT.jar:2.3.0-SNAPSHOT]
at org.apache.storm.daemon.supervisor.Supervisor.main(Supervisor.java:201) [storm-server-2.3.0-SNAPSHOT.jar:2.3.0-SNAPSHOT]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
I think I know what's going on here now. As @agresch mentioned, this issue can be reproduced by When supervisor starts, it reads defaults.yaml, storm.yaml and the command option, then validate the configs. storm/storm-server/src/main/java/org/apache/storm/daemon/supervisor/Supervisor.java Line 126 in 7bef73a
storm/storm-client/src/jvm/org/apache/storm/utils/ConfigUtils.java Lines 438 to 442 in 7bef73a
However, the object type of storm/storm-client/src/jvm/org/apache/storm/utils/Utils.java Lines 287 to 298 in f451be2
On the other hand, the object type of storm/storm-client/src/jvm/org/apache/storm/utils/Utils.java Lines 179 to 182 in f451be2
But the storm/storm-client/src/jvm/org/apache/storm/validation/ConfigValidation.java Lines 404 to 415 in 7bef73a
It will pass the check if the value has Changing the
like
will give us:
when the command is With that being said, I am okay with reverting the code back to original to fix this issue STORM-3727. Filed a separate jira at https://issues.apache.org/jira/browse/STORM-3734 |
What is the purpose of the change
Apparently it is possible for supervisorConf.getOrDefault(DaemonConfig.SUPERVISOR_SLOTS_PORTS) to return a list of Long values, which caused a ClassCastException.
How was the change tested
Built storm-server jar.