Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-42587

Windows: MASTER_POS_WAIT() takes the binlog position modulo 2^32, so it returns 0 at once for position 4294967297, which the replica has not reached

    XMLWordPrintable

Details

    Description

      Likely cause: old code in Item_master_pos_wait::val_int(), not a recent change. The cast is from 2003, and MySQL 5.5 to 26.10 on Windows give the same result.

      --source include/master-slave.inc
      --let $f= query_get_value(SHOW MASTER STATUS, File, 1)
      --sync_slave_with_master
      --eval SET @r= MASTER_POS_WAIT('$f', 4294967297, 1)
      --let $r= query_get_value(SELECT @r AS r, r, 1)
      --source include/rpl_end.inc
      if ($r != -1)
      {
        --die MASTER_POS_WAIT returned $r at once for position 4294967297 of $f: it waited for position 1, 4294967297 mod 2^32
      }

      Leads to:

      CS 13.1.2 8d58226507635114bf4547ce4e10a61f3e578c00 (Debug, MSVC 19.44.35228) Build 26/11/2026

      mysqltest: At line 9: MASTER_POS_WAIT returned 0 at once for position 4294967297 of master-bin.000001: it waited for position 1, 4294967297 mod 2^32

      MASTER_POS_WAIT() should wait until the replica reaches the position, or return -1 after the timeout. On Windows, it takes the position modulo 2^32, so 4294967297 becomes 1, which the replica has passed, and it returns 0 at once. On Linux, the testcase waits 1 second and returns -1.

      4294967296 and 8589934593 also give 0 at once. For 5000000000 the function waits for the wrong position: its note says Timeout waiting for master-bin.000001:705032704. A negative position, which gives NULL on Linux, becomes 4294967295, so MASTER_POS_WAIT('master-bin.000001', -1, 1) waits and returns -1. Positions below 2^32 give the same result on both. Debug and optimized builds give the same result.

      MySQL 5.5, 5.7, 8.0, 8.4 and 26.10 on Windows give the same result, and so does SOURCE_POS_WAIT() in MySQL 8.0 and later.

      From the code it seems that Item_master_pos_wait::val_int() (sql/item_func.cc) casts the position to ulong, which has 32 bits on Windows, before it passes it to Relay_log_info::wait_for_pos(), which takes a longlong.

      Attachments

        Issue Links

          Activity

            People

              Elkin Andrei Elkin
              Roel Roel Van de Paar
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 0.25h
                  0.25h

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.