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

storage: Support adding vector index in background #9411

Merged

Conversation

Lloyd-Pottiger
Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger commented Sep 5, 2024

What problem does this PR solve?

Issue Number: ref #9032

Problem Summary:

What is changed and how it works?

storage: Support adding vector index in background

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
    • STORAGE_FORMAT_CURRENT is bumped to STORAGE_FORMAT_V7

Documentation

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

Release note

None

@ti-chi-bot ti-chi-bot bot added 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. labels Sep 5, 2024
Signed-off-by: Wish <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Co-authored-by: Wish <[email protected]>
Co-authored-by: JaySon-Huang <[email protected]>
}
else if (global_context->getSharedContextDisagg()->isDisaggregatedStorageMode())
{
global_context->initializeGlobalLocalIndexerScheduler(
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain this math?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

initialize the LocalIndexerScheduler introduce by #9383, all vector index build task will be schedule by this scheduler.

Copy link
Member

Choose a reason for hiding this comment

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

I checked that PR, and I can not figure out why it is * 8 / 10

Copy link
Contributor Author

Choose a reason for hiding this comment

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

// There is no compute task in write node.
// Set the pool size to 80% of logical cores and 60% of memory
// to take full advantage of the resources and avoid blocking other tasks like writes and compactions.

Add some comments.

Signed-off-by: Lloyd-Pottiger <[email protected]>
{
RUNTIME_CHECK(segment != nullptr);

// TODO(local index): There could be some indexes are built while some indexes is not yet built after DDL
Copy link
Member

Choose a reason for hiding this comment

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

There could be some indexes are being built?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just ignore it, will remove it in a later PR.

for (const auto & seg_id : segment_ids)
{
auto segment = id_to_segment[seg_id];
auto new_segment = segmentUpdateMeta(lock, dm_context, segment, new_dmfiles);
Copy link
Member

Choose a reason for hiding this comment

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

In segmentUpdateMeta, we will acquire a lock for using Lock = std::unique_lock<std::recursive_mutex>; of a DeltaValueSpace for a Segment, while we are holding also a unique_lock of DM.
I wonder if the lock is too grain? AFAIK, the segment lock is only used in replaceStableMetaVersion. So I wonder if we could do replaceStableMetaVersion without DM lock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Accquiring DM lock to make sure segment will not be abandoned by other thread.

Signed-off-by: Lloyd-Pottiger <[email protected]>
Copy link
Contributor

@JaySon-Huang JaySon-Huang left a comment

Choose a reason for hiding this comment

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

Directly bump the version for supporting building index on both DeltaVS and StableVS

dbms/src/Storages/FormatVersion.h Outdated Show resolved Hide resolved
dbms/src/Server/Server.cpp Outdated Show resolved Hide resolved
dbms/src/Server/Server.cpp Outdated Show resolved Hide resolved
dbms/src/Server/Server.cpp Outdated Show resolved Hide resolved
dbms/src/Server/Server.cpp Outdated Show resolved Hide resolved
dbms/src/Server/Server.cpp Outdated Show resolved Hide resolved
dbms/src/Server/Server.cpp Outdated Show resolved Hide resolved
Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

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

The change looks minimal compared as CSE version.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Sep 19, 2024
Signed-off-by: Lloyd-Pottiger <[email protected]>
@@ -1470,8 +1465,11 @@ SegmentPtr Segment::replaceStableMetaVersion(

wbs.writeAll();

LOG_DEBUG(log, "ReplaceStableMetaVersion - Finish, new_stable_files={}", new_stable_files_str());

LOG_DEBUG(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest LOG_INFO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will print info log in DeltaMergeStore::segmentUpdateMeta

Signed-off-by: Lloyd-Pottiger <[email protected]>
Copy link
Contributor

@JaySon-Huang JaySon-Huang 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 lgtm label Sep 19, 2024
Copy link
Contributor

ti-chi-bot bot commented Sep 19, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: breezewish, JaySon-Huang

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [JaySon-Huang,breezewish]

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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 19, 2024
Copy link
Contributor

ti-chi-bot bot commented Sep 19, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-19 07:08:47.757187927 +0000 UTC m=+1117797.497611866: ☑️ agreed by breezewish.
  • 2024-09-19 10:22:20.042917048 +0000 UTC m=+1129409.783340986: ☑️ agreed by JaySon-Huang.

@ti-chi-bot ti-chi-bot bot merged commit 19cecc1 into pingcap:feature/vector-index Sep 19, 2024
5 checks passed
@Lloyd-Pottiger Lloyd-Pottiger deleted the add-index-background branch September 19, 2024 10:46
@JaySon-Huang JaySon-Huang mentioned this pull request Sep 30, 2024
12 tasks
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants