Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error logging for crc32 validation failures. #563

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions 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 @@ -58,6 +59,11 @@ def _verify_event(self):
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 not self._is_event_valid:
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