Skip to content

Commit e9719ae

Browse files
committed
Swallow KeyErr for meta DROP updates with missing keyspace
Makes control connection robust against out-of-order async events when it doesn't matter (if KS is already gone, sub-component is dropped).
1 parent a327ab1 commit e9719ae

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

cassandra/metadata.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,31 +210,37 @@ def usertype_changed(self, keyspace, name, type_results):
210210
new_usertype = self._build_usertype(keyspace, type_results[0])
211211
self.keyspaces[keyspace].user_types[name] = new_usertype
212212
else:
213-
# the type was deleted
214-
self.keyspaces[keyspace].user_types.pop(name, None)
213+
try:
214+
self.keyspaces[keyspace].user_types.pop(name, None)
215+
except KeyError:
216+
pass
215217

216218
def function_changed(self, keyspace, function, function_results):
217219
if function_results:
218220
new_function = self._build_function(keyspace, function_results[0])
219221
self.keyspaces[keyspace].functions[function.signature] = new_function
220222
else:
221-
# the function was deleted
222-
self.keyspaces[keyspace].functions.pop(function.signature, None)
223+
try:
224+
self.keyspaces[keyspace].functions.pop(function.signature, None)
225+
except KeyError:
226+
pass
223227

224228
def aggregate_changed(self, keyspace, aggregate, aggregate_results):
225229
if aggregate_results:
226230
new_aggregate = self._build_aggregate(keyspace, aggregate_results[0])
227231
self.keyspaces[keyspace].aggregates[aggregate.signature] = new_aggregate
228232
else:
229-
# the aggregate was deleted
230-
self.keyspaces[keyspace].aggregates.pop(aggregate.signature, None)
233+
try:
234+
self.keyspaces[keyspace].aggregates.pop(aggregate.signature, None)
235+
except KeyError:
236+
pass
231237

232238
def table_changed(self, keyspace, table, cf_results, col_results, triggers_result):
233239
try:
234240
keyspace_meta = self.keyspaces[keyspace]
235241
except KeyError:
236242
# we're trying to update a table in a keyspace we don't know about
237-
log.error("Tried to update schema for table '%s' in unknown keyspace '%s'",
243+
log.warn("Tried to update schema for table '%s' in unknown keyspace '%s'",
238244
table, keyspace)
239245
return
240246

0 commit comments

Comments
 (0)