【问题标题】:Confluent Schema Registry : Schema ID deletionConfluent Schema Registry:模式ID删除
【发布时间】:2020-01-25 15:14:08
【问题描述】:

我们正在开发并尝试删除主题的架构,因为更改与旧架构不兼容。

我们删除了架构/主题并尝试在相同的主题名称下创建新架构,并且架构已成功创建。

但是,当我们运行应用程序时,它仍然指向相同的架构 ID。

旧架构 ID(用于主题“topic1”):51

新架构 ID(用于主题“topic1”):52

应用程序因反序列化消息错误而失败

    at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:736)
Caused by: org.apache.kafka.common.errors.SerializationException: Error deserializing Avro message for id 51
Caused by: org.apache.avro.AvroTypeException: Found string, expecting union
    at org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:292)
    at org.apache.avro.io.parsing.Parser.advance(Parser.java:88)
    at org.apache.avro.io.ResolvingDecoder.readIndex(ResolvingDecoder.java:267)
    at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumRea

root@bas:/# curl -k https://schemaregistry:443/subjects/topic1/versions/latest

{"subject":"topic1","version":15,"id":52,"schema":"{\"type\":\"record\",\"name\":\"TopicOutputOutput\",\"namespace\":\"com.sagar.avsc\",\"fields\":[{\"name\":\"id\",\"type\":\"long\"},{\"name\":\"client\",\"type\":{\"type\":\"record\",\"name\":\"ClientObject\",\"fields\":[{\"name\":\"name\",\"type\":[\"null\",\"string\"]},{\"name\":\"client_id\",\"type\":[\"null\",\"long\"]},{\"name\":\"source_system_id\",\"type\":[\"null\",\"long\"]}]}},  ... 

改变: {\"name\":\"client_id\",\"type\":[\"null\",\"long\"]}

您可以看到架构 ID 为 52,但应用程序正在尝试较旧的架构 ID (51),这与我们发送的数据不兼容

root@bas:/#  curl -k https://schemaregistry:443/schemas/ids/52
{"schema":"{\"type\":\"record\",\"name\":\"TopicOutputOutput\",\"namespace\":\"com.sagar.avsc\",\"fields\":[{\"name\":\"id\",\"type\":\"long\"},{\"name\":\"client\",\"type\":{\"type\":\"record\",\"name\":\"ClientObject\",\"fields\":[{\"name\":\"name\",\"type\":[\"null\",\"string\"]},{\"name\":\"client_id\",\"type\":[\"null\",\"long\"]},{\"name\":\"source_system_id\",

改变: {\"name\":\"name\",\"type\":[\"null\",\"string\"]}

为什么应用程序仍然引用旧模式 ID ?有没有办法删除 Schema ID ?

【问题讨论】:

    标签: apache-kafka avro confluent-schema-registry confluent-platform


    【解决方案1】:

    您可以向/subjects/:name/versions/:version发出DELETE

    但是,模式 ID 51 仍然在主题中,在这些特定消息过期或在压缩主题的情况下被墓碑删除之前,无法从那里删除它。

    如果模式不兼容,那么我会检查注册表的配置,因为默认情况下,它不允许向后不兼容的更改。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-13
      • 1970-01-01
      • 2021-10-04
      • 2019-05-01
      • 2021-01-11
      • 2023-01-11
      • 2022-12-27
      • 1970-01-01
      相关资源
      最近更新 更多