Skip to content

Conversation

@Denovo1998
Copy link
Contributor

@Denovo1998 Denovo1998 commented Mar 8, 2023

PR that may be relevant: #10367

Motivation

There is no need to double-check whether the type of the existing schema is different from that of the new schema.

if (existingSchema.schema.getType() != schema.getType()) {
result.completeExceptionally(new IncompatibleSchemaException(
String.format("Incompatible schema: exists schema type %s, new schema type %s",
existingSchema.schema.getType(), schema.getType())));
} else {
try {
checkCompatible(existingSchema, schema, strategy);
result.complete(null);
} catch (IncompatibleSchemaException e) {
result.completeExceptionally(e);
}
}
return result;

private void checkCompatible(SchemaAndMetadata existingSchema, SchemaData newSchema,
SchemaCompatibilityStrategy strategy) throws IncompatibleSchemaException {
SchemaHash existingHash = SchemaHash.of(existingSchema.schema);
SchemaHash newHash = SchemaHash.of(newSchema);
SchemaData existingSchemaData = existingSchema.schema;
if (newSchema.getType() != existingSchemaData.getType()) {
throw new IncompatibleSchemaException(String.format("Incompatible schema: "
+ "exists schema type %s, new schema type %s",
existingSchemaData.getType(), newSchema.getType()));
}
if (!newHash.equals(existingHash)) {
compatibilityChecks.getOrDefault(newSchema.getType(), SchemaCompatibilityCheck.DEFAULT)
.checkCompatible(existingSchemaData, newSchema, strategy);
}
}

Modifications

Remove type checks for existing schemas and new schemas outside org.apache.pulsar.broker.service.schema.SchemaRegistryServiceImpl#checkCompatible(SchemaAndMetadata, SchemaData, SchemaCompatibilityStrategy). And check at the beginning in checkCompatible.

Verifying this change

  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: Denovo1998#3

…ema is different from that of the new schema.
@315157973 315157973 closed this Mar 10, 2023
@315157973 315157973 reopened this Mar 10, 2023
@Denovo1998
Copy link
Contributor Author

/pulsarbot run-failure-checks

@Denovo1998
Copy link
Contributor Author

/pulsarbot run-failure-checks

@Denovo1998
Copy link
Contributor Author

It's strange that upload to codecov always fails.

@Denovo1998
Copy link
Contributor Author

/pulsarbot run-failure-checks

1 similar comment
@Denovo1998
Copy link
Contributor Author

/pulsarbot run-failure-checks

@Denovo1998
Copy link
Contributor Author

@315157973 I guess we can merge in now.

@315157973 315157973 merged commit 0ffa97e into apache:master Mar 16, 2023
@Denovo1998 Denovo1998 deleted the clean-schema-checkCompatible-code branch March 18, 2023 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants