Skip to content

[improve][broker] log incompatible schema failures at warn level, rather than logging at error level - #26804

Open
poorbarcode wants to merge 1 commit into
apache:masterfrom
poorbarcode:improve/log_put_incompatable_schema
Open

poorbarcode wants to merge 1 commit into
apache:masterfrom
poorbarcode:improve/log_put_incompatable_schema

Conversation

@poorbarcode

@poorbarcode poorbarcode commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Schema compatibility validation failures can be wrapped in CompletionException. The schema registry previously checked only the outer exception type, causing expected incompatible-schema failures to be logged as errors. Unwrapping the completion exception allows these expected validation failures to be logged at WARN level while preserving ERROR logging for unexpected failures.

You can reproduce it by the test SchemaServiceTest.checkIsCompatible -> case 3 -> assertThatThrownBy(() -> putSchema(...)

2026-10-01T13:25:26,800+0000 [BookKeeperClientWorker-OrderedExecutor-1-0] WARN  org.apache.pulsar.broker.service.schema.SchemaRegistryServiceImpl - [public/default/tp] Schema is incompatible
2026-10-01T13:25:26,801+0000 [BookKeeperClientWorker-OrderedExecutor-1-0] ERROR org.apache.pulsar.broker.service.schema.SchemaRegistryServiceImpl - [public/default/tp] Put schema failed
java.util.concurrent.CompletionException: org.apache.pulsar.broker.service.schema.exceptions.IncompatibleSchemaException: Error during schema compatibility check with strategy FULL: org.apache.avro.SchemaValidationException: Unable to read schema: 
{...}
	at java.base/java.util.concurrent.CompletableFuture.encodeRelay(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture.completeRelay(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture.complete(Unknown Source)
	at org.apache.pulsar.broker.service.schema.BookkeeperSchemaStorage$Functions.lambda$getLedgerEntry$0(BookkeeperSchemaStorage.java:711)
	at org.apache.bookkeeper.client.LedgerHandle$6.onSuccess(LedgerHandle.java:1050)
	at org.apache.bookkeeper.client.LedgerHandle$6.onSuccess(LedgerHandle.java:1047)
	at org.apache.bookkeeper.common.concurrent.FutureEventListener.accept(FutureEventListener.java:42)
	at org.apache.bookkeeper.common.concurrent.FutureEventListener.accept(FutureEventListener.java:26)
	at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$Completion.run(Unknown Source)
	at org.apache.bookkeeper.common.util.SingleThreadExecutor.safeRunTask(SingleThreadExecutor.java:128)
	at org.apache.bookkeeper.common.util.SingleThreadExecutor.run(SingleThreadExecutor.java:99)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.apache.pulsar.broker.service.schema.exceptions.IncompatibleSchemaException: Error during schema compatibility check with strategy FULL: org.apache.avro.SchemaValidationException
...
...

Modifications

Correct log level. Since it is a log level change, it is hard to add a verification for it, I did not modify the test

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

@poorbarcode poorbarcode changed the title [improve][log] log incompatible schema failures at warn level, rather… [improve][broker] log incompatible schema failures at warn level, rather… Oct 1, 2026
@poorbarcode poorbarcode changed the title [improve][broker] log incompatible schema failures at warn level, rather… [improve][broker] log incompatible schema failures at warn level, rather than logging at error level Oct 1, 2026
var latencyMs = this.clock.millis() - start.longValue();
if (ex != null) {
if (ex instanceof IncompatibleSchemaException) {
if (actEx instanceof IncompatibleSchemaException) {

@merlimat merlimat Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@poorbarcode We could also use exceptionMessage() instead of exception() cause we don't need the full stacktrace. And log actEx instead of ex

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.

4 participants