Skip to content

vector: Fix building vector index on DeltaVS may lead to delta compact failure (#10311)#10353

Merged
ti-chi-bot[bot] merged 2 commits intopingcap:release-8.5from
ti-chi-bot:cherry-pick-10311-to-release-8.5
Sep 1, 2025
Merged

vector: Fix building vector index on DeltaVS may lead to delta compact failure (#10311)#10353
ti-chi-bot[bot] merged 2 commits intopingcap:release-8.5from
ti-chi-bot:cherry-pick-10311-to-release-8.5

Conversation

@ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #10311

What problem does this PR solve?

Issue Number: close #10310, ref #9600

Problem Summary: Introduced by #9546 in the vector update workload

In DeltaMergeStore::segmentEnsureDeltaLocalIndex, the function will update the persisted ColumnFiles in DeltaVS.

// Update the column files in the delta with the new column files.
for (auto & column_file : delta_persisted_column_files)
{
const auto * tiny_file = column_file->tryToTinyFile();
if (!tiny_file)
continue;
if (auto iter = new_column_files_map.find(tiny_file->getDataPageId()); iter != new_column_files_map.end())
column_file = iter->second;
}
delta_persisted_file_set->updatePersistedColumnFilesAfterAddingIndex(delta_persisted_column_files, wbs);

In ColumnFilePersistedSet::installCompactionResults it will check whether the persisted ColumnFiles are changed during the minor compaction. If the persisted ColumnFiles not matched, it will throw an exception as the issue describe.
auto old_persisted_files_iter = persisted_files.begin();
for (const auto & task : compaction->getTasks())
{
for (const auto & file : task.to_compact)
{
if (unlikely(
old_persisted_files_iter == persisted_files.end()
|| (file->getId() != (*old_persisted_files_iter)->getId())
|| (file->getRows() != (*old_persisted_files_iter)->getRows())))
{
throw Exception(
ErrorCodes::LOGICAL_ERROR,
"Compaction algorithm broken, "
"compaction={{{}}} persisted_files={} "
"old_persisted_files_iter.is_end={} "
"file->getId={} old_persist_files->getId={} file->getRows={} old_persist_files->getRows={}",
compaction->info(),
detailInfo(),
old_persisted_files_iter == persisted_files.end(),
file->getId(),
old_persisted_files_iter == persisted_files.end() ? -1 : (*old_persisted_files_iter)->getId(),
file->getRows(),
old_persisted_files_iter == persisted_files.end() ? -1 : (*old_persisted_files_iter)->getRows());
}
old_persisted_files_iter++;
}
}

So the issue is cause by local index on the DeltaVS changed the persisted ColumnFiles between Minor Compaction.

What is changed and how it works?

* In `DeltaMergeStore::segmentEnsureDeltaLocalIndexAsync` and `DeltaMergeStore::segmentWaitDeltaLocalIndexReady` if we detect that `segment->getDelta()->isUpdating()`, it means the segment is running an update task (SegmentMergeDelta/SegmentMerge/SegmentSplit), just skip the local index build job
* `ColumnFilePersistedSet::installCompactionResults` if we detect the column file set is changed during minor compaction, then log an error and rollback the minor compaction
* `WriteBatches::rollbackWrittenLogAndData` will also remove the pending `removed_log` and `removed_data`

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: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Aug 20, 2025
@ti-chi-bot
Copy link
Member Author

@JaySon-Huang This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 20, 2025

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Aug 20, 2025
Signed-off-by: JaySon-Huang <tshent@qq.com>
@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 29, 2025
@JaySon-Huang
Copy link
Contributor

/unhold
conflict are resolved

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 29, 2025
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Aug 29, 2025
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 1, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Sep 1, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-08-29 10:47:43.766644701 +0000 UTC m=+523555.644475655: ☑️ agreed by JaySon-Huang.
  • 2025-09-01 02:31:47.217030744 +0000 UTC m=+752999.094861708: ☑️ agreed by Lloyd-Pottiger.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Sep 1, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, JinheLin, Lloyd-Pottiger

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:
  • OWNERS [JaySon-Huang,JinheLin,Lloyd-Pottiger]

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 merged commit 1bcc11e into pingcap:release-8.5 Sep 1, 2025
2 of 4 checks passed
@ti-chi-bot ti-chi-bot bot deleted the cherry-pick-10311-to-release-8.5 branch September 1, 2025 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved cherry-pick-approved Cherry pick PR approved by release team. lgtm 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. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants