-
Notifications
You must be signed in to change notification settings - Fork 684
Add properties in gtid event #586
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: main
Are you sure you want to change the base?
Add properties in gtid event #586
Conversation
@Bue-von-hon |
@sean-k1 here is the official mysql documentation and the url of the cpp implementation that I referenced. Please see the Binary Format section in Mysql: https://dev.mysql.com/doc/dev/mysql-server/8.1.0/classbinary__log_1_1Gtid__event.html You can see the binary format starting at line 428 of the CPP implementation. |
self.assertIsInstance(gtid_event.sid, bytes) | ||
self.assertIsInstance(gtid_event.gno, int) | ||
self.assertIsInstance(gtid_event.lt_type, int) | ||
self.assertIsInstance(gtid_event.last_committed, int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upper mysql 5.7 version has this variable so pytest failed.
- base.py make method isMySQL57AndMore
- Test setUp method use isMySQL57AndMore* before start Test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolves it!
@sean-k1 Leave a comment about the test. PTAL🙏 Summary: Details: In the isMySQL57AndMore method of the PyMySQLReplicationTestCase class written in base.py, I am getting the correct mysql version information (8.1 in my case). So, the reason for the test failure is as follows if self.mysql_version >= (5, 7):
self.last_committed = struct.unpack("<Q", self.packet.read(8))[0]
self.sequence_number = struct.unpack("<Q", self.packet.read(8))[0] p.s. I'm not sure if I should fix this bug in this PR. Why not create a new issue and fix it? |
Motivation: GtidEvent is aleady implemented but there are missing 6 properties. If we respect these properties, user can use GtidEvent with more convenient. Motivation: - Fix(event.py): Add two properties. - Add(test_basic.py): Add test for GtidEvent. Result: for now on, user can use read_immediate_commit_timestamp and read_original_commit_timestamp properties.
Co-authored-by: sean.k1 (Umhyunsik) <sean.k1@kakaoent.com>
f200a56
to
e6b2a54
Compare
Co-authored-by: sean.k1 (Umhyunsik) <sean.k1@kakaoent.com>
self.execute( | ||
"CREATE TABLE IF NOT EXISTS test (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255))" | ||
) | ||
gtid_event = self.stream.fetchone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should grep FormatEvent too
Now gtid_event assign FormatDescriptionEvent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After i grep FormatDescriptionEvent, test was passed in my local env. 👍
@Bue-von-hon |
I have read the mysql release notes you attached. |
5.7 users will get an error and terminate the process if they use this version I'm not sure if branching based on myql version is a good idea either, so I'll think about it a bit more. |
@Bue-von-hon @sean-k1 I have already created a similar method bytes_to_read in python-mysql-replication but I would have to say the implementation isn't necessarily elegant. In case you haven't configured mysql-server locally, refer to following GitHub links and code blocks for details on the implementation of can_read in mysql-server. /**
Returns if the Event_reader can read a given amount of bytes from cursor
position.
@param bytes the amount of bytes expected to be read.
@retval true if the Event_reader can read the specified amount of bytes.
@retval false if the Event_reader cannot read the specified amount of bytes.
*/
bool can_read(unsigned long long bytes) {
return (available_to_read() >= bytes);
} /**
Returns the amount of bytes still available to read from cursor position.
@return the amount of bytes still available to read.
*/
unsigned long long available_to_read() {
BAPI_ASSERT(position() <= m_limit);
return m_limit - position();
} /**
Returns the current Event_reader cursor position in bytes.
@retval m_limit if cursor position is invalid.
@retval position current Event_reader cursor position (if valid).
*/
unsigned long long position() {
return m_ptr >= m_buffer ? m_ptr - m_buffer : m_limit;
} |
Description
Motivation:
GtidEvent is aleady implemented but there are missing 6 properties.
If we respect these properties, user can use GtidEvent with more convenient.
Motification:
Result:
for now on, user can use read_immediate_commit_timestamp and read_original_commit_timestamp properties.
Type of Change
Checklist
Tests