Kafka 在架构注册表中创建新架构时未找到主题错误代码40401

o4tp2gmn  于 2023-06-05  发布在  Apache
关注(0)|答案(1)|浏览(181)
[2023-05-30 14:11:39,104] INFO 10.237.87.231 - - [30/May/2023:14:11:39 +0000] "GET /subjects/MY_TOPIC-key/versions/latest HTTP/1.1" 404 68 "-" "Java/11.0.17" 2 (io.confluent.rest-utils.requests)
[2023-05-30 14:11:39,109] INFO Registering new schema: subject MY_TOPIC-key, version null, id null, type null, schema size 177 (io.confluent.kafka.schemaregistry.rest.resources.SubjectVersionsResource)
[2023-05-30 14:11:39,118] INFO 10.237.87.231 - - [30/May/2023:14:11:39 +0000] "POST /subjects/MY_TOPIC-key/versions?normalize=false HTTP/1.1" 200 11 "-" "Java/11.0.17" 10 (io.confluent.rest-utils.requests)
[2023-05-30 14:11:39,120] ERROR Request Failed with exception  (io.confluent.rest.exceptions.DebuggableExceptionMapper)
io.confluent.rest.exceptions.RestNotFoundException: Subject 'MY_TOPIC-key' not found.
    at io.confluent.kafka.schemaregistry.rest.exceptions.Errors.subjectNotFoundException(Errors.java:77)
    at io.confluent.kafka.schemaregistry.rest.resources.SubjectVersionsResource.getSchemaByVersion(SubjectVersionsResource.java:141)
    at jdk.internal.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)

我想使用akhq GUI注册新模式,但我得到了错误主题未找到。我不明白这个错误。当我想创建新模式时,为什么主题应该存在?

更新

我试着用curl创建它:
curl -X POST -H“内容类型:application/vnd.schemaregistry.v1+json”-k --data @key http://my-custom-schemaregistry.org/subjects/MY_TOPIC-value/versions?normalize=false
它返回schema ID 123,但当我尝试GET时:
http://my-custom-schemaregistry.org/schemas/ids/123
我得到了:

{"error_code":40403,"message":"Schema 123 not found"}

更新2

在日志中,我可以看到新模式:

[2023-05-30 21:37:26,752] INFO Registering new schema: subject TEST_TEMP, version null, id null, type null, schema size 756 (io.confluent.kafka.schemaregistry.rest.resources.SubjectVersionsResource)
[2023-05-30 21:37:26,765] INFO 10.237.87.231 - - [30/May/2023:21:37:26 +0000] "POST /subjects/TEST_TEMP/versions?normalize=false HTTP/1.1" 200 11 "-" "Java/11.0.17" 14 (io.confluent.rest-utils.requests)
[2023-05-30 21:37:26,766] ERROR Request Failed with exception  (io.confluent.rest.exceptions.DebuggableExceptionMapper)
io.confluent.rest.exceptions.RestNotFoundException: Subject 'TEST_TEMP' not found.
odopli94

odopli941#

为什么要在创建新模式时存在主题
因为你发布了一个 * 新版本 * 到一个主题,即使这是第一个版本。
您可以从"GET /subjects/MY_TOPIC-key/versions/latest HTTP/1.1" 404中看到,它必须首先查找最新版本,然后才能注册,以便注册表执行向后兼容性检查
对于第一个注册的版本,您应该忽略这些日志。您无法在服务器上禁用它们。

相关问题