Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

issue-907 : Debug assertion "last_val > 0" when auto_inc_inc > 1 and …#908

Open
george-lorch wants to merge 1 commit into
facebook:fb-mysql-5.6.35from
george-lorch:issue-907
Open

issue-907 : Debug assertion "last_val > 0" when auto_inc_inc > 1 and …#908
george-lorch wants to merge 1 commit into
facebook:fb-mysql-5.6.35from
george-lorch:issue-907

Conversation

@george-lorch

Copy link
Copy Markdown

…ullong_max underflow

  • Fixed a minor logic problem in ha_rocksdb::get_auto_increment when the
    auto_increment_increment is > 1 and we run into the condition where
    the next auto increment value is ullong_max+1, which is 0. When this occurs,
    the next call into ha_rocksdb::get_auto_increment will debug assert on
    'last_val > 0'.

  • Added an autoincrement overflow test that runs through a 10*10 matrix of
    auto_increment_increment and auto_increment_offset values that all bump up
    against the ullong_max overflow. Without the logic fix in place, a vast
    majority of the combinations within the matrix would hit the debug assertion.

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lth has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be slightly nicer if this were in a while loop too.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it seems that mtr doesn't support nested while loops, or at least I couldn't get it to work :-\

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first glance, it looks like this sequence failed before reaching 18446744073709551614, but it's really just because we didn't do enough inserts to hit the overflow case.

Can we fix this case?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, you are correct, I didn't execute enough inserts for the increment=1 cases to overflow.

Comment thread storage/rocksdb/ha_rocksdb.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extend the comment above to explain why we do this -1/+1 business? The original std::min expression was probably copied from the inc == 1 case.

…ullong_max underflow

- Fixed a minor logic problem in ha_rocksdb::get_auto_increment when the
  auto_increment_increment is > 1 and we run into the condition where
  the next auto increment value is ullong_max+1, which is 0.  When this occurs,
  the next call into ha_rocksdb::get_auto_increment will debug assert on
  'last_val > 0'.

- Added an autoincrement overflow test that runs through a 10*10 matrix of
  auto_increment_increment and auto_increment_offset values that all bump up
  against the ullong_max overflow.  Without the logic fix in place, a vast
  majority of the combinations within the matrix would hit the debug assertion.
@facebook-github-bot

Copy link
Copy Markdown

@georgelorchpercona has updated the pull request. Re-import the pull request

CREATE TABLE t1(c1 BIGINT UNSIGNED AUTO_INCREMENT, KEY (c1)) ENGINE=ROCKSDB AUTO_INCREMENT=18446744073709551604;
SET @@session.auto_increment_increment=10, @@session.auto_increment_offset=1;
SELECT * FROM t1;
c1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These "empty" selects were also a bit worrying so I looked into them. It looks like we actually return ER_WARN_DATA_OUT_OF_RANGE in this case, because compute_next_insert_id overflows. Maybe we can add a comment in the test explaining when we get that error?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

3 participants