Bug #41961 Some log_event types do not skip post-header when reading
Submitted: 8 Jan 2009 14:03 Modified: 20 Jan 2009 21:58
Reporter: Sven Sandberg Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:5.1+ OS:Any
Assigned to: Sven Sandberg CPU Architecture:Any
Tags: log_event, post-header

[8 Jan 2009 14:03] Sven Sandberg
Description:
Each log_event has a common-header, post-header, and data section. The common-header length is fixed for all event types but may differ between server versions (e.g,. 19 bytes in 5.1). The post-header length is the same for all events of a given type and server version, but may differ for events of different types or events generated by different server versions. The length of the data part varies from event to event.

The common-header and post-header lengths are defined in the Format_description_log_event, and the data length is defined in each event.

When an event is read from file (e.g., by the slave IO thread from the relay log, or by mysqlbinlog), and the server that reads the file has different lengths of the two headers than the server that wrote the file, then the server that reads the file can use the information in Format_description_log_event to parse the event correctly.

In the current implementation, the following events have post-header length 0:

  INTVAR_EVENT
  RAND_EVENT
  USER_VAR_EVENT
  XID_EVENT

Hence, all their data belongs to the data part. However, the reader functions for these events do *not* read the post-header length from the Format_description_log_event. So if a future server version adds bytes to the post-header of these events, the current version will not be able to read the future version. (This may happen, e.g., if we implement event checksums.)

How to repeat:
read the code

Suggested fix:
Make INTVAR, RAND, USER_VAR, and XID skip the post-header length before they read their data parts.
[8 Jan 2009 14:26] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/62698

2711 Sven Sandberg	2009-01-08
      BUG#41961: Some log_event types do not skip post-header when reading
      Problem: when the server reads a log_event from file, it should read
      the post-header lengths from the format_description_log_event. Some
      event types which currently have post-header length 0 did not do this,
      and instead had a hard-coded zero length for the post-header. That
      means the current server version will not be able to read future
      versions of these events.
      Fix: make the reader functions read the post-header.
[8 Jan 2009 15:38] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/62709

2711 Sven Sandberg	2009-01-08
      BUG#41961: Some log_event types do not skip post-header when reading
      Problem: when the server reads a log_event from file, it should read
      the post-header lengths from the format_description_log_event. Some
      event types which currently have post-header length 0 did not do this,
      and instead had a hard-coded zero length for the post-header. That
      means the current server version will not be able to read future
      versions of these events.
      Fix: make the reader functions read the post-header.
[9 Jan 2009 9:38] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/62779

2711 Sven Sandberg	2009-01-09
      BUG#41961: Some log_event types do not skip post-header when reading
      Problem: when the server reads a log_event from file, it should read
      the post-header lengths from the format_description_log_event. Some
      event types which currently have post-header length 0 did not do this,
      and instead had a hard-coded zero length for the post-header. That
      means the current server version will not be able to read future
      versions of these events.
      Fix: make the reader functions read the post-header.
[9 Jan 2009 9:46] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/62780

2726 Sven Sandberg	2009-01-09
      BUG#41961: Some log_event types do not skip post-header when reading
      Problem: when the server reads a log_event from file, it should read
      the post-header lengths from the format_description_log_event. Some
      event types which currently have post-header length 0 did not do this,
      and instead had a hard-coded zero length for the post-header. That
      means the current server version will not be able to read future
      versions of these events.
      Fix: make the reader functions read the post-header.
[9 Jan 2009 9:53] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/62781

2943 Sven Sandberg	2009-01-09 [merge]
      Merged BUG#41961 from 5.1-rpl -> 6.0-rpl.
      One conflict in log_event.cc resolved manually.
[9 Jan 2009 10:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/62788

2727 Sven Sandberg	2009-01-09 [merge]
      merge fix of BUG#41961 in 5.1-bugteam with recent changes in 5.1-bugteam
[9 Jan 2009 10:35] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/62789

2728 Sven Sandberg	2009-01-09 [merge]
      Merged fix of BUG#41961 in 5.1-bugteam with recent changes in 5.1-bugteam
[9 Jan 2009 10:38] Sven Sandberg
pushed to 5.1-bugteam and 6.0-bugteam
[15 Jan 2009 6:38] Bugs System
Pushed into 5.1.31 (revid:joro@sun.com-20090115053147-tx1oapthnzgvs1ro) (version source revid:davi.arnaut@sun.com-20090113150631-y84w12o2zmh7j3qd) (merge vers: 5.1.31) (pib:6)
[16 Jan 2009 20:02] Jon Stephens
Documented in the 5.1.31 changelog as follows:

        Some log_event types did not skip the
        post-header when reading.

Set status to NDI pending merge to 6.0.
[19 Jan 2009 11:28] Bugs System
Pushed into 5.1.31-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090119095303-uwwvxiibtr38djii) (version source revid:tomas.ulin@sun.com-20090115073240-1wanl85vlvw2she1) (merge vers: 5.1.31-ndb-6.2.17) (pib:6)
[19 Jan 2009 13:06] Bugs System
Pushed into 5.1.31-ndb-6.3.21 (revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (version source revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (merge vers: 5.1.31-ndb-6.3.21) (pib:6)
[19 Jan 2009 14:03] Jon Stephens
Set status back to NDI pending merge to 6.0 tree.
[19 Jan 2009 16:12] Bugs System
Pushed into 5.1.31-ndb-6.4.1 (revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (version source revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (merge vers: 5.1.31-ndb-6.4.1) (pib:6)
[19 Jan 2009 17:07] Jon Stephens
Set back to NDI pending merge to 6.0.
[20 Jan 2009 18:58] Bugs System
Pushed into 6.0.10-alpha (revid:joro@sun.com-20090119171328-2hemf2ndc1dxl0et) (version source revid:mats@sun.com-20090109123108-m97xwc0c1048bxik) (merge vers: 6.0.10-alpha) (pib:6)
[20 Jan 2009 21:58] Jon Stephens
Fix also documented in the 6.0.10 changelog; closed.