-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Pulsar SQL] Fix Pulsar SQL query bytes schema data error #9631
Conversation
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
@@ -441,9 +442,11 @@ public boolean advanceNextPosition() { | |||
//start time for deseralizing record | |||
metricsTracker.start_RECORD_DESERIALIZE_TIME(); | |||
|
|||
SchemaInfo schemaInfo; | |||
SchemaInfo schemaInfo = getBytesSchemaInfo(pulsarSplit.getSchemaType(), pulsarSplit.getSchemaName()); |
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 noticed the current getSchemaVersion
in the RawMessageImpl
return null
@Override
public byte[] getSchemaVersion() {
if (msgMetadata != null && msgMetadata.getMetadata().hasSchemaVersion()) {
return msgMetadata.getMetadata().getSchemaVersion();
} else {
return null;
}
}
It should not throw java.nio.BufferUnderflowException
. Could you please confirm here?
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 method may cause the exception java.nio.BufferUnderflowException
.
private SchemaInfo loadSchema(BytesSchemaVersion bytesSchemaVersion) throws PulsarAdminException {
ClassLoader originalContextLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(InjectionManagerFactory.class.getClassLoader());
return pulsarAdmin.schemas()
.getSchemaInfo(topicName.toString(), ByteBuffer.wrap(bytesSchemaVersion.get()).getLong());
} finally {
Thread.currentThread().setContextClassLoader(originalContextLoader);
}
}
The schema version of Schema.BYTES
is an empty bytes array. So ByteBuffer.wrap(bytesSchemaVersion.get()).getLong()
will cause the exception java.nio.BufferUnderflowException
.
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 see.
if (!schemaType.equals(SchemaType.BYTES) && !schemaType.equals(SchemaType.NONE)) { | ||
return null; | ||
} | ||
if (schemaName.equals(Schema.BYTES.getSchemaInfo().getName())) { |
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.
Can you compare SchemaType instead of comparing schemaName?
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.
The schema types of the Schema.BYTES
and Schema.BYTEBUFFER
all are SchemaType.BYTES
, so I use the schema name to make the comparison.
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.
Okay. Make sense.
e73e177
to
4633855
Compare
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
This issue is introduced by #8422. So it not a bug fix for the 2.7.0. Removed the |
Motivation
Currently, the Pulsar SQL query bytes schema data will cause an error.
Reproduce
Error log
Modifications
Add check for bytes schema, if the schema is bytes schema use the schema info of the bytes schema directly.
Verifying this change
Add a new integration test for different schemas.
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changes