Skip to content
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

Allow to serialize negative thread pool sizes #6486

Merged

Conversation

spinscale
Copy link
Contributor

As a SizeValue is used for serializing the thread pool size, a negative number
resulted in throwing an exception when deserializing (using -ea an assertionerror
was thrown).

This fixes a check for changing the serialization logic, so that negative numbers are read correctly.

Closes #6325
Closes #5357

@spinscale
Copy link
Contributor Author

Note: There are several solutions to this problem. My first approach was to allow -1 in SizeValue, but I think a size value should always be positive and serializing this using writeLong instead of writeVLong seemed wasteful. This is why I opted for the ThreadPool.Info to either be a sizevalue or -1, as this setting is implementation specific to the threadpool.

Also, the bwc layer could potentially be removed for master.

Maybe someone has a better idea

@Test(expected = AssertionError.class)
public void testThatNegativeQueueSizesThrowExceptionInOldVersions() throws Exception {
ThreadPool.Info info = new ThreadPool.Info("foo", "search", 1, 10, TimeValue.timeValueMillis(3000), SizeValue.parseSizeValue("-1"));
output.setVersion(Version.V_1_2_1);
Copy link
Member

Choose a reason for hiding this comment

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

maybe randomize the version a bit here?

@s1monw
Copy link
Contributor

s1monw commented Jul 9, 2014

@spinscale can you pick this up any time soon or should somebody else pick it up?

@spinscale
Copy link
Contributor Author

@s1monw updated the PR, feel free to take another look. SizeValue now does not accept a -1 value, but when parsing from a string it automatically sets it to unbounded.. added test to ensure that reading -1 as setting still works as expected as well as serialization

@@ -173,7 +177,9 @@ public static SizeValue parseSizeValue(String sValue, SizeValue defaultValue) th
}
long singles;
try {
if (sValue.endsWith("b")) {
if (sValue.equals("-1")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we should not handle this in here... we should special case this in ThreadPool.java and maybe just use null as the value for the queue or move the UNBOUNDED sentinel there.

@s1monw s1monw removed the review label Jul 15, 2014
@s1monw
Copy link
Contributor

s1monw commented Jul 15, 2014

I left comments on the latest push

@spinscale
Copy link
Contributor Author

added the UNBOUNDED size value to ThreadPool.. allowed SizeValue to be negative again and added some unit tests for it

out.writeBoolean(isQueueSizeBounded);
if (isQueueSizeBounded) {
queueSize.writeTo(out);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

this else clause is unnecessary or infact wrong :) no? we should not write UNBOUNDED

@s1monw
Copy link
Contributor

s1monw commented Jul 15, 2014

ok so now I am a bit lost... I don't get why we add unittests for SizeValue with negative values? didn't we fix this before to make sure you can't pass a negative value?

@s1monw s1monw added v1.3.0 and removed v1.4.0 labels Jul 16, 2014
@spinscale
Copy link
Contributor Author

oh boy, thats what happens when you push things before hopping on a plane after giving a workshop all day, sorry for that! back to throwing an exception and and incorporated your review comment

@s1monw
Copy link
Contributor

s1monw commented Jul 16, 2014

LGTM

As a SizeValue is used for serializing the thread pool size, a negative number
resulted in throwing an exception when deserializing (using -ea an assertionerror
was thrown).

This fixes a check for changing the serialization logic, so that negative numbers are read correctly, by adding an internal UNBOUNDED value.

Closes elastic#6325
Closes elastic#5357
@spinscale spinscale merged commit b0c0ff8 into elastic:master Jul 16, 2014
spinscale added a commit that referenced this pull request Jul 16, 2014
…ization

This fixes an issue introduced by the serialization changes in #6486
which are not needed at all. Node that the serialization itself is not broken
but the TransportClient uses its own version on initial connect and getting
the NodeInfos.
spinscale added a commit that referenced this pull request Jul 16, 2014
…ization

This fixes an issue introduced by the serialization changes in #6486
which are not needed at all. Node that the serialization itself is not broken
but the TransportClient uses its own version on initial connect and getting
the NodeInfos.
spinscale added a commit that referenced this pull request Jul 16, 2014
…ization

This fixes an issue introduced by the serialization changes in #6486
which are not needed at all. Node that the serialization itself is not broken
but the TransportClient uses its own version on initial connect and getting
the NodeInfos.
spinscale added a commit that referenced this pull request Jul 16, 2014
…ization

This fixes an issue introduced by the serialization changes in #6486
which are not needed at all. Node that the serialization itself is not broken
but the TransportClient uses its own version on initial connect and getting
the NodeInfos.
@clintongormley clintongormley changed the title Threadpool Info: Allow to serialize negative thread pool sizes Internal: Allow to serialize negative thread pool sizes Jul 23, 2014
@clintongormley clintongormley changed the title Internal: Allow to serialize negative thread pool sizes Allow to serialize negative thread pool sizes Jun 7, 2015
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
…ization

This fixes an issue introduced by the serialization changes in elastic#6486
which are not needed at all. Node that the serialization itself is not broken
but the TransportClient uses its own version on initial connect and getting
the NodeInfos.
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
…ization

This fixes an issue introduced by the serialization changes in elastic#6486
which are not needed at all. Node that the serialization itself is not broken
but the TransportClient uses its own version on initial connect and getting
the NodeInfos.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serialization of queue size is broken RemoteTransportException when trying to access :9200/_nodes
4 participants