{"record":{"id":"8a13023862502c1d","repo":"apache/pulsar","slug":"interrupted-at-fetching-schema-info-for-schemauti","errorCode":null,"errorMessage":"Interrupted at fetching schema info for <SchemaUtils.getStringSchemaVersion(schemaVersion)>","messagePattern":"Interrupted at fetching schema info for <SchemaUtils\\.getStringSchemaVersion\\(schemaVersion\\)>","errorType":"exception","errorClass":"SerializationException","httpStatus":null,"severity":"warning","filePath":"pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/reader/AbstractMultiVersionReader.java","lineNumber":125,"sourceCode":"    }\n\n    /**\n     * Load the schema reader for reading messages encoded by the given schema version.\n     *\n     * @param schemaVersion the provided schema version\n     * @return the schema reader for decoding messages encoded by the provided schema version.\n     */\n    protected abstract SchemaReader<T> loadReader(BytesSchemaVersion schemaVersion);\n\n    /**\n     * TODO: think about how to make this async.\n     */\n    protected SchemaInfo getSchemaInfoByVersion(byte[] schemaVersion) {\n        try {\n            return schemaInfoProvider.getSchemaByVersion(schemaVersion).get();\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            throw new SerializationException(\n                    \"Interrupted at fetching schema info for \" + SchemaUtils.getStringSchemaVersion(schemaVersion),\n                    e\n            );\n        } catch (ExecutionException e) {\n            throw new SerializationException(\n                    \"Failed at fetching schema info for \" + SchemaUtils.getStringSchemaVersion(schemaVersion),\n                    e.getCause()\n            );\n        }\n    }\n}\n","sourceCodeStart":107,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/reader/AbstractMultiVersionReader.java#L107-L137","documentation":"getSchemaInfoByVersion blocks on the CompletableFuture from schemaInfoProvider.getSchemaByVersion(...).get(). If that waiting thread is interrupted, the interrupt flag is restored and a SerializationException 'Interrupted at fetching schema info for <version>' is thrown. It means schema lookup was cancelled by thread shutdown or interruption, not a schema problem itself.","triggerScenarios":"Calling getSchemaInfoByVersion (used inside read paths) while the calling thread is interrupted — e.g. consumer closed during decode, executor shutdown, or application shutdown interrupting schema fetch.","commonSituations":"Shutting down consumers/producers while messages are still being decoded; timeouts that cancel/interrupt worker threads; test frameworks interrupting threads; long schema fetches interrupted by user-initiated close.","solutions":["Avoid closing/interrupting the consumer while decoding is in flight; close gracefully","Preserve the interrupt status and abort the current operation cleanly (the library already re-interrupts)","Increase shutdown timeouts so workers finish before interruption","Check for code in your app that interrupts client threads (Thread.interrupt, ExecutorService.shutdownNow)","Retry the operation on a fresh, non-interrupted thread if appropriate"],"exampleFix":"// before\nexecutor.shutdownNow(); // interrupts in-flight schema fetch -> SerializationException\n// after\nexecutor.shutdown();\nif (!executor.awaitTermination(30, TimeUnit.SECONDS)) {\n    executor.shutdownNow();\n}","handlingStrategy":"try-catch","validationCode":"if (Thread.currentThread().isInterrupted()) {\n    // do not start schema fetch; abort current decode gracefully\n    return null;\n}","typeGuard":"null","tryCatchPattern":"try {\n    SchemaInfo info = reader.getSchemaInfoByVersion(version);\n} catch (SerializationException e) {\n    if (Thread.currentThread().isInterrupted()) {\n        // shutdown in progress: stop work, do not swallow interrupt\n        throw e;\n    }\n    // otherwise retry on a clean thread\n}","preventionTips":["Close consumers gracefully and wait for in-flight decodes before shutdown","Avoid ExecutorService.shutdownNow on threads running Pulsar client code","Use timeouts at your own layer instead of interrupting client threads","Keep schema fetches fast by ensuring broker reachability"],"tags":["pulsar","schema","interruption","threading"],"backgroundTag":"thread-interrupted","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}