Skip to content

FFI: Fix NPE when GetLockByKey is called when region is not exist#9914

Merged
ti-chi-bot[bot] merged 6 commits intopingcap:masterfrom
JaySon-Huang:fix_get_lock
Feb 26, 2025
Merged

FFI: Fix NPE when GetLockByKey is called when region is not exist#9914
ti-chi-bot[bot] merged 6 commits intopingcap:masterfrom
JaySon-Huang:fix_get_lock

Conversation

@JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented Feb 25, 2025

What problem does this PR solve?

Issue Number: close #9915

Problem Summary:
There could be a chance that GetLockByKey is called when region is not exist
And returning BaseBuffView to rust is not memory safe

What is changed and how it works?

Pending on pingcap/tidb-engine-ext#426

FFI: Fix NPE when GetLockByKey is called when region is not exist
FFI: Use CppStrWithView as the return type of fn_get_lock_by_key

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed do-not-merge/needs-linked-issue labels Feb 25, 2025
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
@JaySon-Huang JaySon-Huang changed the title [DNM] FFI: Fix NPE when GetLockByKey is called when region is not exist FFI: Fix NPE when GetLockByKey is called when region is not exist Feb 26, 2025
Signed-off-by: JaySon-Huang <tshent@qq.com>
Copy link
Member

@CalvinNeo CalvinNeo left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Feb 26, 2025
Signed-off-by: JaySon-Huang <tshent@qq.com>
auto restored_segments = checkpoint_info->getRestoredSegments();
auto updated_segments = ingestSegmentsUsingSplit(dm_context, range, restored_segments);
auto estimated_bytes = 0;
size_t estimated_bytes = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

auto in here unexpectedly lead to negative value because the compiler use int32 for the auto. And collecting the bytes of restored_segment could larger than 2GiB.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Feb 26, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CalvinNeo, JinheLin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 26, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Feb 26, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-02-26 06:37:30.472824271 +0000 UTC m=+424198.425982529: ☑️ agreed by CalvinNeo.
  • 2025-02-26 10:36:31.952732307 +0000 UTC m=+438539.905890573: ☑️ agreed by JinheLin.

@ti-chi-bot ti-chi-bot bot merged commit 65aeb16 into pingcap:master Feb 26, 2025
5 checks passed
@JaySon-Huang JaySon-Huang deleted the fix_get_lock branch February 26, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TiFlash crash at RegionData::getLockByKey

3 participants