apache/pulsar

Schema properties are not updated if schema definition does not change

Open

#7,564 创建于 2020年7月16日

在 GitHub 查看
 (3 评论) (0 反应) (1 负责人)Java (3,485 fork)batch import
area/schemahelp wantedtype/bug

仓库指标

Star
 (13,697 star)
PR 合并指标
 (平均合并 3天 10小时) (30 天内合并 146 个 PR)

描述

Describe the bug The only available operation to update properties of a schema (SchemaInfo) is to use createSchema() method of PulsarAdmin. The problem with that is that it will not update the provided properties if schema definition does not change.

The only way the admin API provides to update the properties associated with an schema is to delete it first and then create it from scratch. This can be dangerous because if schema creation fails aftewards we will be left with an unreadable topic (missing schema) and also different consumers using different schema versions may also face issues (when we delete an schema all versions are deleted).

To Reproduce

PulsarAdmin client = createClient();
String topicUri = getTopicUri();

SchemaInfo info = client.schemas().getSchemaInfo(topicUri);

/*
 * We add a new property
 */
info.getProperties().put("newProp", "newValue");

PostSchemaPayload sp = new PostSchemaPayload();
sp.setType(info.getType().toString());
sp.setSchema(info.getSchemaDefinition());
sp.setProperties(info.getProperties());

/* 
 * This should update schema properties
 */ 
client.schemas().createSchema(topicUri, sp);

/*
 * This object does not contain "newProp" 
 */
info = client.schemas().getSchemaInfo(topicUri);

Expected behavior Method to create/update schema should update properties even if schema definition does not change.

Screenshots

Desktop (please complete the following information):

  • Windows with Docker Desktop

Additional context

贡献者指南