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

fix crash when schema version is greater than 255 #3893

Merged
merged 2 commits into from
Feb 15, 2022

Conversation

critical27
Copy link
Contributor

@critical27 critical27 commented Feb 15, 2022

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

#3889

Description:

Crash because of out-of-range access in vector.
The byte order of schema version in meta is not same as numerical order.

version (INT64_MAX - version) in hex rocksdb (INT64_MAX - version) little endian
0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
1 ff ff ff ff ff ff ff fe fe ff ff ff ff ff ff ff
... ... ...
255 ff ff ff ff ff ff ff 00 00 ff ff ff ff ff ff ff
256 ff ff ff ff ff ff fe ff ff fe ff ff ff ff ff ff
... ... ...

The output order in rocksdb when we prefix scan is quite complicated, just say a simple example with 257 schema versions in range [0, 256], the order will be: 255 254 253 ... 3 2 1 256 0

How do you solve it?

Just resize to make sure the vector is valid.

Special notes for your reviewer, ex. impact of this fix, design document, etc:

Checklist:

Tests:

  • Unit test(positive and negative cases)
  • Function test
  • Performance test
  • N/A

Affects:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatibility (If it breaks the compatibility, please describe it and add the label.)
  • If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to be reflected in release notes and how to describe:
Bug fix, fix crash when schema versions are more than 256

liwenhui-soul
liwenhui-soul previously approved these changes Feb 15, 2022
@Sophie-Xie Sophie-Xie added cherry-pick-v3.0 PR: need cherry-pick to this version cherry-pick-v2.6 PR: need cherry-pick to this version ready-for-testing PR: ready for the CI test labels Feb 15, 2022
CPWstatic
CPWstatic previously approved these changes Feb 15, 2022
@critical27 critical27 dismissed stale reviews from CPWstatic and liwenhui-soul via d70e001 February 15, 2022 09:01
@critical27
Copy link
Contributor Author

Talked with @yixinglu offline, forbid the Gherkin format check now

liwenhui-soul
liwenhui-soul previously approved these changes Feb 15, 2022
CPWstatic
CPWstatic previously approved these changes Feb 15, 2022
pengweisong
pengweisong previously approved these changes Feb 15, 2022
Copy link
Contributor

@pengweisong pengweisong left a comment

Choose a reason for hiding this comment

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

Good job~

@critical27 critical27 merged commit 9de3ead into vesoft-inc:master Feb 15, 2022
@critical27 critical27 deleted the hot branch February 15, 2022 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-v2.6 PR: need cherry-pick to this version cherry-pick-v3.0 PR: need cherry-pick to this version ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants