Skip to content

Commit c83d3da

Browse files
authored
fix: update schema registry cache after deleting subject (#1825)
Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
1 parent c8a8b47 commit c83d3da

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/confluent_kafka/schema_registry/schema_registry_client.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,26 @@ def set(self, schema_id, schema, subject_name=None):
215215
if subject_name is not None:
216216
self.subject_schemas[subject_name].add(schema)
217217

218+
def remove_by_subject(self, subject_name):
219+
"""
220+
Remove a Schema from the cache.
221+
222+
Args:
223+
subject_name (str): Subject name the schema is registered under.
224+
"""
225+
226+
227+
with self.lock:
228+
if subject_name in self.subject_schemas:
229+
for schema in self.subject_schemas[subject_name]:
230+
schema_id = self.schema_index.get(schema, None)
231+
if schema_id is not None:
232+
self.schema_id_index.pop(schema_id, None)
233+
self.schema_index.pop(Schema, None)
234+
235+
del self.subject_schemas[subject_name]
236+
237+
218238
def get_schema(self, schema_id):
219239
"""
220240
Get the schema instance associated with schema_id from the cache.
@@ -546,7 +566,9 @@ def delete_subject(self, subject_name, permanent=False):
546566
if permanent:
547567
self._rest_client.delete('subjects/{}?permanent=true'
548568
.format(_urlencode(subject_name)))
549-
569+
570+
self._cache.remove_by_subject(subject_name)
571+
550572
return list
551573

552574
def get_latest_version(self, subject_name):

0 commit comments

Comments
 (0)