Skip to content

Commit

Permalink
Add error logging for crc32 validation failures
Browse files Browse the repository at this point in the history
Co-authored-by: jaehyeonpy jaehyeonpy@gmail.com
Co-authored-by: davinc71998 davinc71998@gmail.com
  • Loading branch information
why-arong committed Oct 18, 2023
1 parent c639f47 commit bbae27f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pymysqlreplication/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datetime
import decimal
import zlib
import logging

from pymysqlreplication.constants.STATUS_VAR_KEY import *
from pymysqlreplication.exceptions import StatusVariableMismatch
Expand Down Expand Up @@ -57,7 +58,14 @@ def _verify_event(self):
data = self.packet.read(19 + self.event_size)
footer = self.packet.read(4)
byte_data = zlib.crc32(data).to_bytes(4, byteorder="little")
self._is_event_valid = True if byte_data == footer else False
if byte_data == footer:
self._is_event_valid = True
else:
self._is_event_valid = False
logging.error(
f"An CRC32 has failed for the event type {self.event_type}, "
"indicating a potential integrity issue with the data."
)
self.packet.read_bytes -= 19 + self.event_size + 4
self.packet.rewind(20)

Expand Down

0 comments on commit bbae27f

Please sign in to comment.