Skip to content

engine_rocks: introduce force_partition_range in compact guard#18866

Merged
ti-chi-bot[bot] merged 12 commits intotikv:masterfrom
glorv:fore-partition-range
Aug 29, 2025
Merged

engine_rocks: introduce force_partition_range in compact guard#18866
ti-chi-bot[bot] merged 12 commits intotikv:masterfrom
glorv:fore-partition-range

Conversation

@glorv
Copy link
Contributor

@glorv glorv commented Aug 21, 2025

What is changed and how it works?

Issue Number: Close #18865

What's Changed:

- introduce `force_partition_range` in compact guard to force partition specific range to ensure SST ingestion under this range can be ingested to the bottom level.
- Add 2 new API in SST service to manage the `force_partition_range`. The `add_force_partition_range` will also trigger a manual compaction to ensure existing SST will be partitioned.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

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

Release note

None

glorv added 4 commits August 21, 2025 10:30
Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: glorv <glorvs@163.com>
@ti-chi-bot ti-chi-bot bot added dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 21, 2025
glorv added 4 commits August 21, 2025 12:14
Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: glorv <glorvs@163.com>
Copy link
Member

@Connor1996 Connor1996 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 the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 21, 2025
&[]
};

tikv_util::info!("sst partition due to force partition ranges";
Copy link
Member

Choose a reason for hiding this comment

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

It seems that self.current_next_level_size >= self.max_compaction_size may also bring us here. I know it is just for logging, but do we need to distinguish it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


// ingest a sst with a big range
let (mut meta, data) =
gen_sst_file_with_tidb_kvs(sst_path.clone(), &[(b"a", b"a"), (b"z", b"z")], None);
Copy link
Member

Choose a reason for hiding this comment

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

Insteading of ingest a generated SST, how about writing to TiKV with txn APIs. Because there is a key encoding logic in add_force_partition_range

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is a tricky workaround, because we need to write a large amount of data to let rocksdb trigger flush and generate sst files. So I just let gen_sst_file_with_tidb_kvs generate the rocksdb format data kv, there should be no difference.

Copy link
Member

@v01dstar v01dstar left a comment

Choose a reason for hiding this comment

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

rest LGTM

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

ti-chi-bot bot commented Aug 23, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-08-21 22:40:30.589940523 +0000 UTC m=+566038.533116029: ☑️ agreed by Connor1996.
  • 2025-08-23 06:35:58.40648288 +0000 UTC m=+680966.349658397: ☑️ agreed by v01dstar.

Copy link
Member

@hbisheng hbisheng left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +142 to +143
let ttl = r.ttl.saturating_duration_since(now);
if ttl == Duration::ZERO {
Copy link
Member

Choose a reason for hiding this comment

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

nit: use a consistent style for time comparison

Suggested change
let ttl = r.ttl.saturating_duration_since(now);
if ttl == Duration::ZERO {
let expired = r.ttl < now;
if expired {

struct TtlRange {
start: Vec<u8>,
end: Vec<u8>,
ttl: Instant,
Copy link
Member

Choose a reason for hiding this comment

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

nit: TTL usually means a duration rather than a time point. expires_at is probably better.

Suggested change
ttl: Instant,
expires_at: Instant,

Signed-off-by: glorv <glorvs@163.com>
@glorv
Copy link
Contributor Author

glorv commented Aug 27, 2025

/hold waiting for pingcap/kvproto#1340

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 27, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 28, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Connor1996, v01dstar, zhangjinpeng87

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 the approved label Aug 28, 2025
@glorv
Copy link
Contributor Author

glorv commented Aug 29, 2025

/retest

@ti-chi-bot ti-chi-bot bot merged commit 3899697 into tikv:master Aug 29, 2025
8 checks passed
@ti-chi-bot ti-chi-bot bot added this to the Pool milestone Aug 29, 2025
@glorv glorv deleted the fore-partition-range branch August 29, 2025 01:51
ti-chi-bot bot pushed a commit that referenced this pull request Sep 1, 2025
close #18912

Fix the incorrect assert of compaction guard introduced by #18866.

Signed-off-by: glorv <glorvs@163.com>
yibin87 pushed a commit to yibin87/tikv that referenced this pull request Sep 2, 2025
…v#18866)

close tikv#18865

- introduce `force_partition_range` in compact guard to force partition specific range to ensure SST ingestion under this range can be ingested to the bottom level.
- Add 2 new API in SST service to manage the `force_partition_range`. The `add_force_partition_range` will also trigger a manual compaction to ensure existing SST will be partitioned.

Signed-off-by: glorv <glorvs@163.com>
yibin87 pushed a commit to yibin87/tikv that referenced this pull request Sep 2, 2025
close tikv#18912

Fix the incorrect assert of compaction guard introduced by tikv#18866.

Signed-off-by: glorv <glorvs@163.com>
@glorv glorv added needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. labels Sep 8, 2025
ti-chi-bot pushed a commit to ti-chi-bot/tikv that referenced this pull request Sep 8, 2025
close tikv#18865

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #18934.
But this PR has conflicts, please resolve them!

ti-chi-bot pushed a commit to ti-chi-bot/tikv that referenced this pull request Sep 8, 2025
close tikv#18865

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #18935.
But this PR has conflicts, please resolve them!

ti-chi-bot pushed a commit to ti-chi-bot/tikv that referenced this pull request Sep 8, 2025
close tikv#18865

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #18936.
But this PR has conflicts, please resolve them!

glorv added a commit to ti-chi-bot/tikv that referenced this pull request Sep 8, 2025
close tikv#18912

Fix the incorrect assert of compaction guard introduced by tikv#18866.

Signed-off-by: glorv <glorvs@163.com>
ti-chi-bot bot pushed a commit that referenced this pull request Sep 18, 2025
) (#18934)

close #18865

- introduce `force_partition_range` in compact guard to force partition specific range to ensure SST ingestion under this range can be ingested to the bottom level.
- Add 2 new API in SST service to manage the `force_partition_range`. The `add_force_partition_range` will also trigger a manual compaction to ensure existing SST will be partitioned.

Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>

Co-authored-by: glorv <glorvs@163.com>
Co-authored-by: lucasliang <nkcs_lykx@hotmail.com>
3AceShowHand pushed a commit to 3AceShowHand/tikv that referenced this pull request Oct 13, 2025
…v#18866)

close tikv#18865

- introduce `force_partition_range` in compact guard to force partition specific range to ensure SST ingestion under this range can be ingested to the bottom level.
- Add 2 new API in SST service to manage the `force_partition_range`. The `add_force_partition_range` will also trigger a manual compaction to ensure existing SST will be partitioned.

Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: 3AceShowHand <jinl1037@hotmail.com>
3AceShowHand pushed a commit to 3AceShowHand/tikv that referenced this pull request Oct 13, 2025
close tikv#18912

Fix the incorrect assert of compaction guard introduced by tikv#18866.

Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: 3AceShowHand <jinl1037@hotmail.com>
Leavrth pushed a commit to Leavrth/tikv that referenced this pull request Oct 21, 2025
…v#18866)

close tikv#18865

- introduce `force_partition_range` in compact guard to force partition specific range to ensure SST ingestion under this range can be ingested to the bottom level.
- Add 2 new API in SST service to manage the `force_partition_range`. The `add_force_partition_range` will also trigger a manual compaction to ensure existing SST will be partitioned.

Signed-off-by: glorv <glorvs@163.com>
Leavrth pushed a commit to Leavrth/tikv that referenced this pull request Oct 21, 2025
close tikv#18912

Fix the incorrect assert of compaction guard introduced by tikv#18866.

Signed-off-by: glorv <glorvs@163.com>
@glorv glorv restored the fore-partition-range branch November 17, 2025 06:35
@glorv glorv deleted the fore-partition-range branch November 17, 2025 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unexpect sst ingestion in l0 even if there is no overlapped data

6 participants