Skip to content

Commit df6fd50

Browse files
ivotustanicclaude
andauthored
[O11YINFRA-109] catch AssertionError from bmemcached on malformed binary protocol responses (DataDog#22650)
* fix(mcache): catch AssertionError from bmemcached on malformed binary protocol responses The bmemcached library throws AssertionError when the binary protocol magic byte doesn't match expectations (e.g., corrupted or partial response under high load). This error was not caught by the check's exception handler, causing the entire check to crash with an unhandled AssertionError instead of reporting a proper CRITICAL service check. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * handle AssertionError separately: log warning instead of raising ConfigurationError --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent eb5baa2 commit df6fd50

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

mcache/changelog.d/22650.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Handle malformed binary protocol responses from `bmemcached` gracefully. Instead of crashing with an unhandled `AssertionError`, the check now logs a warning and reports a `WARNING` service check, allowing the next check run to retry.

mcache/datadog_checks/mcache/mcache.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,16 @@ def check(self, instance):
305305
server, port, e
306306
)
307307
)
308+
except AssertionError:
309+
self.warning(
310+
"Received malformed response from memcache instance %s:%s, skipping this check run", server, port
311+
)
312+
self.service_check(
313+
self.SERVICE_CHECK,
314+
AgentCheck.WARNING,
315+
tags=service_check_tags,
316+
message="Malformed binary protocol response",
317+
)
308318
else:
309319
client.disconnect_all()
310320
self.log.debug("Disconnected from memcached")

0 commit comments

Comments
 (0)