-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[flaky-tests] AdminApiSchemaTest#testSchemaInfoApi #14508
[flaky-tests] AdminApiSchemaTest#testSchemaInfoApi #14508
Conversation
I wonder why pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AbstractSchema.java Lines 68 to 70 in 16beb9d
|
/pulsarbot rerun-failure-checks |
@@ -708,7 +709,7 @@ public void testNullKeyValueProperty() throws PulsarAdminException, PulsarClient | |||
map.put(null, "value"); // null key is not allowed for JSON, it's only for test here | |||
|
|||
// leave INT32 instance unchanged | |||
final Schema<Integer> integerSchema = Schema.INT32.clone(); | |||
final Schema<Integer> integerSchema = DefaultImplementation.getDefaultImplementation().newIntSchema(); |
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 not good.
it means that users that use the public API Schema.INT32 and use clone() see surprises.
I believe that the problem is that clone() is not working properly
Schema are stateful objects in Pulsar and clone() is very important
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.
if you don't want to open the Pandora box of clone() then please use Schema.JSON() that is guaranteed to always return a new instance
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.
I don't believe this solution works. SCHEMA_INFO
is static, so any modification of it in one test will affect other tests. This is a design flaw.
A larger question for me is why we're letting users modify the SCHEMA_INFO
object. It is static, so cloning isn't going to do anything.
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.
@michaeljmarshall good catch! you're right
I think the test issue can be just fixed as @eolivelli suggested, using a JSON schema. The type of the schema is not relevant for test itself.
I agree that the clone()
method returnsthis
because, probably, the initial intention was to keep it immutable.
Moving the getter to return an immutable map may be the right solution, even if it can be considered a breaking change because can cause runtime error while upgrading the client
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.
Great point. In order to get this test passing, we can avoid the mutability issues for Schema.INT32
.
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.
@lhotari - it's likely that clone
returns this because it is supposed to be immutable. Unfortunately, the SCHEMA_INFO
is static and mutable, so this bug would exist even if clone worked properly.
@nicoloboschi - great work identifying this issue. I think we'll need to discuss a large solution. In my mind, the SCHEMA_INFO
shouldn't be modifiable in this case.
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/IntSchema.java
Lines 31 to 40 in 16beb9d
private static final IntSchema INSTANCE; | |
private static final SchemaInfo SCHEMA_INFO; | |
static { | |
SCHEMA_INFO = new SchemaInfoImpl() | |
.setName("INT32") | |
.setType(SchemaType.INT32) | |
.setSchema(new byte[0]); | |
INSTANCE = new IntSchema(); | |
} |
@@ -708,7 +709,7 @@ public void testNullKeyValueProperty() throws PulsarAdminException, PulsarClient | |||
map.put(null, "value"); // null key is not allowed for JSON, it's only for test here | |||
|
|||
// leave INT32 instance unchanged | |||
final Schema<Integer> integerSchema = Schema.INT32.clone(); | |||
final Schema<Integer> integerSchema = DefaultImplementation.getDefaultImplementation().newIntSchema(); |
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.
I don't believe this solution works. SCHEMA_INFO
is static, so any modification of it in one test will affect other tests. This is a design flaw.
A larger question for me is why we're letting users modify the SCHEMA_INFO
object. It is static, so cloning isn't going to do anything.
Note also that the properties map (the original issue from #12461) is a mutable map that is likely passed among threads: pulsar/pulsar-common/src/main/java/org/apache/pulsar/client/impl/schema/SchemaInfoImpl.java Lines 62 to 66 in 89a36f9
Depending on how we access this map, that could be its own issue. That |
@michaeljmarshall @eolivelli I created this issue #14522 for continuing the discussion |
/pulsarbot rerun-failure-checks |
i think primitive schema also can implement clone |
There will be some components inside and will change. When the user wants to use the component at that time, we need the clone method to get the current schema, and it will not affect the original schema. Doesn't seem to be of much use in primitive schema as they are all the same |
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.
LGTM
* [flaky-tests] AdminApiSchemaTest#testSchemaInfoApi * use custom json schema * remove old comment ### Motivation This is the same fix applied here #12461. The problem with the other pull is that the `AbstractSchema#clone()` method does return the same instance, so the fix is not useful at all. I see this test also failing in 2.8 and 2.9 branch, I recommend to cherry-pick it. ### Modifications * Create a new INT schema for the test purpose - [x] `no-need-doc` (cherry picked from commit 32c3cd1)
* [flaky-tests] AdminApiSchemaTest#testSchemaInfoApi * use custom json schema * remove old comment ### Motivation This is the same fix applied here #12461. The problem with the other pull is that the `AbstractSchema#clone()` method does return the same instance, so the fix is not useful at all. I see this test also failing in 2.8 and 2.9 branch, I recommend to cherry-pick it. ### Modifications * Create a new INT schema for the test purpose - [x] `no-need-doc` (cherry picked from commit 32c3cd1)
* [flaky-tests] AdminApiSchemaTest#testSchemaInfoApi * use custom json schema * remove old comment ### Motivation This is the same fix applied here #12461. The problem with the other pull is that the `AbstractSchema#clone()` method does return the same instance, so the fix is not useful at all. I see this test also failing in 2.8 and 2.9 branch, I recommend to cherry-pick it. ### Modifications * Create a new INT schema for the test purpose - [x] `no-need-doc` (cherry picked from commit 32c3cd1)
* [flaky-tests] AdminApiSchemaTest#testSchemaInfoApi * use custom json schema * remove old comment ### Motivation This is the same fix applied here apache#12461. The problem with the other pull is that the `AbstractSchema#clone()` method does return the same instance, so the fix is not useful at all. I see this test also failing in 2.8 and 2.9 branch, I recommend to cherry-pick it. ### Modifications * Create a new INT schema for the test purpose - [x] `no-need-doc` (cherry picked from commit 32c3cd1) (cherry picked from commit 0f72a4f)
* [flaky-tests] AdminApiSchemaTest#testSchemaInfoApi * use custom json schema * remove old comment ### Motivation This is the same fix applied here apache#12461. The problem with the other pull is that the `AbstractSchema#clone()` method does return the same instance, so the fix is not useful at all. I see this test also failing in 2.8 and 2.9 branch, I recommend to cherry-pick it. ### Modifications * Create a new INT schema for the test purpose - [x] `no-need-doc` (cherry picked from commit 32c3cd1) (cherry picked from commit 0f72a4f)
* [flaky-tests] AdminApiSchemaTest#testSchemaInfoApi * use custom json schema * remove old comment ### Motivation This is the same fix applied here apache#12461. The problem with the other pull is that the `AbstractSchema#clone()` method does return the same instance, so the fix is not useful at all. I see this test also failing in 2.8 and 2.9 branch, I recommend to cherry-pick it. ### Modifications * Create a new INT schema for the test purpose - [x] `no-need-doc`
* [flaky-tests] AdminApiSchemaTest#testSchemaInfoApi * use custom json schema * remove old comment ### Motivation This is the same fix applied here apache#12461. The problem with the other pull is that the `AbstractSchema#clone()` method does return the same instance, so the fix is not useful at all. I see this test also failing in 2.8 and 2.9 branch, I recommend to cherry-pick it. ### Modifications * Create a new INT schema for the test purpose - [x] `no-need-doc`
Motivation
This is the same fix applied here #12461. The problem with the other pull is that the
AbstractSchema#clone()
method does return the same instance, so the fix is not useful at all.I see this test also failing in 2.8 and 2.9 branch, I recommend to cherry-pick it.
Modifications
no-need-doc