0

I know that the documentation of Confluent says that the schemas cannot be deleted in case of some clueless producer.

BUT I still would like to know if there is any way of deleting a schema from the schema registry, not just deleting a specific schema version of a subject, deleting also the schema ID at all.

Dipperman
  • 119
  • 1
  • 12
  • The ID is stored as part of any given message, not just the registry.... A message cannot be deleted, only expired. Deleting a version in the registry is still going to leave behind any produced messages containing that ID – OneCricketeer Sep 02 '19 at 23:46
  • so there is no way to delete a schema ID to prevent producers to use a old schema ID? – Dipperman Sep 03 '19 at 07:09
  • The problem isn't really the producers... If you deleted an ID **after** the producer already sent the message (which you can't really prevent except one config), you'd get a `404: schema ID not found`, causing the consumer to crash – OneCricketeer Sep 03 '19 at 16:09

1 Answers1

0

You cannot delete the schema directly, rather you have to delete the subject attached to the schema.

You access schema registry url like below to see all the schemas.

https://<schemaregistryurl:port/schemas

So, if your topic name is mytopic, then you must see two schemas in the schema registry with subject named "mytopic-key" and "mytopic-value". Below is an example schema value in "mytopic-value"

{
"subject": "mytopic-value",
"version": 1,
"id": 100423,
"schema": "{"type":"record","name":"User","fields":[{"name":"username","type":"string"},{"name":"phone","type":"long"},{"name":"age","type":"int"}]}"
}

Now if you want to delete this schema, you have to delete the subject. All the subjects are listed on https://<schemaregistryurl:port/subjects

Soft Delete of all schemas regiseterd against the subject

curl -u username:password -X DELETE http://localhost:8081/subjects/mytopic-value

To hard delete you have to pass ?permanent=true

More options for deletions like, selective versions, latest version can be found on the related documentation at https://docs.confluent.io/platform/current/schema-registry/schema-deletion-guidelines.html

Sanjay Bharwani
  • 3,317
  • 34
  • 31