Skip to content

Commit bbae27f

Browse files
committed
Add error logging for crc32 validation failures
Co-authored-by: jaehyeonpy [email protected] Co-authored-by: davinc71998 [email protected]
1 parent c639f47 commit bbae27f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pymysqlreplication/event.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import datetime
44
import decimal
55
import zlib
6+
import logging
67

78
from pymysqlreplication.constants.STATUS_VAR_KEY import *
89
from pymysqlreplication.exceptions import StatusVariableMismatch
@@ -57,7 +58,14 @@ def _verify_event(self):
5758
data = self.packet.read(19 + self.event_size)
5859
footer = self.packet.read(4)
5960
byte_data = zlib.crc32(data).to_bytes(4, byteorder="little")
60-
self._is_event_valid = True if byte_data == footer else False
61+
if byte_data == footer:
62+
self._is_event_valid = True
63+
else:
64+
self._is_event_valid = False
65+
logging.error(
66+
f"An CRC32 has failed for the event type {self.event_type}, "
67+
"indicating a potential integrity issue with the data."
68+
)
6169
self.packet.read_bytes -= 19 + self.event_size + 4
6270
self.packet.rewind(20)
6371

0 commit comments

Comments
 (0)