GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PIP-144: Making SchemaRegistry implementation configurable · Issue #14395 · apache/pulsar

PIP-144: Making SchemaRegistry implementation configurable #14395

New issue
Copy link
New issue
Copy link
Open
Open
PIP-144: Making SchemaRegistry implementation configurable#14395
Copy link
Assignees
aparajita89
Labels
Stalelifecycle/staletype/PIP
Milestone
3.1.0

Description

@aparajita89
aparajita89
opened on Feb 21, 2022
Issue body actions

Motivation

Pulsar comes with an inbuilt schema registry and a pluggable schema storage. Schema storage's default implementation is bookkeeper-based but a new implementation can be provided by the user. Schema registry on the other hand interacts with the configured schema storage and offers ability to do schema CRUD as well as performs compatibility checks.

Since schema registry is not pluggable, it is not possible as of today to enhance/extend what pulsar offers out of the box. This is usually true in organizations where an existing schema registry is already present and used in other systems that producers and consumers interact with. Having a pluggable storage is not sufficient, some of the reasons are:

  • The user may want to cache (schema-version,schema-data) in-memory rather than doing a fetch from schema storage for scaling purposes.
  • The user has a compatibility evaluation logic of their own. For example, the user wants to implement semver-based versioning of schemas with minor versions being forwards-compatible and major versions indicating breaking changes.
  • Additional policies need to be applied to compatibility or schema fetch patterns depending on business requirements and the schema in question.

For above reasons, we are proposing support for a pluggable schema registry in pulsar.

Goal

The scope of this is to make schema registry service pluggable in order to support different forms of versioning and compatibility checks, depending on the use case.

All of the changes are on the broker-side and backwards compatible. Existing schema registry service implementation will continue to remain the default one. Users will be able to provide a different registry by specifying the class name in the broker config and loading the relevant jar on the broker's class path. The experience for pluggable schema registry is going to be the same as the one for pluggable schema storage.

User-facing addition of flag in broker.conf

# Override the schema registry used by pulsar with a custom implementation. If this config is not provided,
# the default schema registry (SchemaRegistryServiceImpl) will be used.
schemaRegistryClassName=

Example of how a custom schema registry can be implemented by the user where they only want to change a certain set of behaviors and reuse the rest.

public class MySchemaRegistry extends SchemaRegistryServiceImpl {
    
    @Override
    public void initialize(ServiceConfiguration configuration, SchemaStorage schemaStorage) throws PulsarServerException {
        super.initialize(configuration, schemaStorage);
        //read config and do some other op
    }
    
    @Override
    public CompletableFuture<List<CompletableFuture<SchemaAndMetadata>>> getAllSchemas(String schemaId) {
        CompletableFuture<List<CompletableFuture<SchemaAndMetadata>>> schemas = super.getAllSchemas(schemaId);
        //apply some filtering logic and return
    }
    
    @Override
    public CompletableFuture<Boolean> isCompatible(String schemaId, SchemaData schema, SchemaCompatibilityStrategy strategy) {
        //custom operation
    }
}

API Changes

Add a configuration parameter to set the schema registry to be used. This is illustrated in the "Goals" section above.
Add an initialize(...) method to SchemaRegistryService interface, similar in lines to the AuthorizationProvider interface already existing in Pulsar. This will ensure initialization of the plugged in schema registry with the required dependencies.

void initialize(ServiceConfiguration configuration, SchemaStorage schemaStorage) throws PulsarServerException;

Implementation

These are the changes covered in the PR:

  • Make the schema registry configurable via broker config. The changes are:
    • Add a new config called schemaRegistryClassName in ServiceConfiguration with a default value of org.apache.pulsar.broker.service.schema.SchemaRegistryServiceImpl
  • Use initialize(...) method instead of constructor to set dependencies like schema storage and compatibility checkers. This is being done to ensure that the contract becomes explicit to the implementer of the interface rather than having an assumption in the codebase around what the constructor params should be. The changes are:
    • Add an initialize(...) method in SchemaRegistryService without an implementation
    • Update create(...) method in SchemaRegistryService to create the instance of schema registry based on the ServiceConfiguration and initialize(...) method, instead of using a particular constructor overload.
  • Renaming a few methods in the SchemaRegistryService interface to reflect their behavior. The changes are:
    • Rename deleteSchema to putEmptySchema in SchemaRegistryService
    • Rename deleteSchemaStorage to deleteSchemaFromStorage in SchemaRegistryService
  • Remove checkCompatible from SchemaRegistryService and make it a private method in SchemaRegistryServiceImpl because it is not used anywhere else
  • Make compatibilityChecks, schemaStorage and clock non-final in the default implementation as they are now being set in initialize(...) method
  • Move getCheckers(...) from SchemaRegistryService to SchemaRegistryServiceImpl since this behavior is tied to how default schema registry implementation works.
  • Move the null check on schemaStorage from SchemaRegistryService to PulsarService. The null check will now be used to decide the name of the schema registry which needs to be instantiated.

This change has been done and a PR has been raised here: #14102

Reject Alternatives

  • We had a requirement to override/change the way compatibility logic is performed in the default schema registry. To that end, it was considered separating out schema validation/compatibility logic into a different interface and impl, similar to how schema storage is modeled as of today. The user will be able to use the default schema registry but influence the behavior of compatibility checks by providing their own implementation.
    We did not end up taking this route because in most of the cases, the default compatibility checks should make sense as-is. And in scenarios where they require change, users can always plug in a new schema registry and use the default schema registry for behavior they want to retain using composition. This is demonstrated in the example given in the "Goals" section.
  • We had a requirement to influence the list of schemas returned by the schema registry. To that end, we considered changing the SchemaStorage implementation itself (which is already pluggable and user-facing as of today). But the filtering needed to be done on the properties in SchemaData/SchemaInfo, and doing the deserialization in the schema storage layer did not match its purpose.

Authors

Aparajita Singh (https://github.com/aparajita89)
Ankur Jain (https://github.com/anvinjain)

Activity

  1. aparajita89
    added
    type/PIP
    on Feb 21, 2022
  2. merlimat
    changed the title [-]Making SchemaRegistry implementation configurable[/-] [+]PIP-144: Making SchemaRegistry implementation configurable[/+] on Feb 23, 2022
  3. codelipenghui
    assigned
    aparajita89
    on Mar 15, 2022
  4. codelipenghui
    added this to the 2.11.0 milestone on Mar 15, 2022
  5. github-actions commented on Apr 15, 2022

    @github-actions
    github-actionsBot
    on Apr 15, 2022
    More actions

    The issue had no activity for 30 days, mark with Stale label.

  6. github-actions
    added
    lifecycle/stale
    on Apr 15, 2022
  7. github-actions commented on May 28, 2022

    @github-actions
    github-actionsBot
    on May 28, 2022
    More actions

    The issue had no activity for 30 days, mark with Stale label.

  8. codelipenghui
    modified the milestones: 2.11.0, 2.12.0 on Jul 26, 2022
  9. RobertIndie
    modified the milestones: 3.0.0, 3.1.0 on Apr 11, 2023
  10. merlimat commented on Oct 24, 2026

    @merlimat
    merlimat
    on Oct 24, 2026
    Contributor
    More actions

    PIP-144 passed its vote (https://lists.apache.org/thread/9tq3c1fwb4kxtp359jg5vr6f1l8ypnml), but it is not implemented: the implementation PR #14102 was closed because the schema code has changed a lot since 2022, and master still has no schemaRegistryClassName setting (only schema storage and compatibility checkers are pluggable). PIP-420 now lets clients use an external schema registry, which covers part of this. A fresh PR against master that points to PIP-144 is still welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @aparajita89
    aparajita89

Labels

Stalelifecycle/staletype/PIP

Type

No type

Projects

No projects

    Milestone

    • 3.1.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.