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

[Feature] Support restoring from a cluster snapshot for shared-data mode (part 3, introduce gtid for tablet metadata) #54326

Conversation

xiangguangyxg
Copy link
Contributor

@xiangguangyxg xiangguangyxg commented Dec 25, 2024

Why I'm doing:

The dirty data must be detected when restoring from a cluster snapshot.

What I'm doing:

Introduce gtid for tablet metadata, gtid will be used for the following:

  1. Check if a tablet metadata version is dirty using gtid during publish version. If the gtid of a tablet metadata version is not equal to the value saved in fe, it indicates that the tablet metadata version is dirty and need to be deleted.
  2. Query versions before a given time for time travel, like select a from b before t.

Fixes #53867

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.4
    • 3.3
    • 3.2
    • 3.1
    • 3.0

@xiangguangyxg xiangguangyxg force-pushed the restore_snapshot_align_data_with_metadata branch 2 times, most recently from 2cda723 to 11f7c5c Compare December 25, 2024 09:39
kevincai
kevincai previously approved these changes Dec 26, 2024
@HangyuanLiu
Copy link
Contributor

The introduction of global transaction id is a very important change. Can you explain its necessity in more detail? I hope you can give some examples.

@@ -70,10 +70,11 @@ public static void buildPartitionsSequentially(long dbId, OlapTable table, List<
int partitionGroupSize = Math.max(1, numBackends * 200 / Math.max(1, avgReplicasPerPartition));
boolean enableTabletCreationOptimization = table.isCloudNativeTableOrMaterializedView()
&& Config.lake_enable_tablet_creation_optimization;
long gtid = GlobalStateMgr.getCurrentState().getGtidGenerator().nextGtid();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is not a good idea to generate a global transaction id here, because it is a low-level function. It is far from the actual meaning of gtid. How can we ensure that a transaction will not call the buildPartition function multiple times? I think it should be placed in the upper-level begin transaction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added option arg to pass the gtid to the low-level function

…ode (part 3, introduce gtid for tablet metadata)

Signed-off-by: xiangguangyxg <[email protected]>
Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[FE Incremental Coverage Report]

pass : 48 / 52 (92.31%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/alter/LakeRollupJob.java 12 15 80.00% [159, 229, 507]
🔵 com/starrocks/alter/LakeTableSchemaChangeJob.java 5 6 83.33% [764]
🔵 com/starrocks/alter/LakeTableAlterMetaJobBase.java 4 4 100.00% []
🔵 com/starrocks/alter/LakeTableSchemaChangeJobBase.java 1 1 100.00% []
🔵 com/starrocks/server/LocalMetastore.java 5 5 100.00% []
🔵 com/starrocks/task/CreateReplicaTask.java 7 7 100.00% []
🔵 com/starrocks/task/TabletTaskExecutor.java 13 13 100.00% []
🔵 com/starrocks/lake/TxnInfoHelper.java 1 1 100.00% []

Copy link

[BE Incremental Coverage Report]

pass : 5 / 5 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/storage/lake/tablet_manager.cpp 1 1 100.00% []
🔵 be/src/storage/lake/transactions.cpp 4 4 100.00% []

@kevincai kevincai merged commit f977337 into StarRocks:main Dec 27, 2024
69 of 71 checks passed
@xiangguangyxg
Copy link
Contributor Author

@mergify backport branch-3.4

Copy link
Contributor

mergify bot commented Dec 27, 2024

backport branch-3.4

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Dec 27, 2024
…ode (part 3, introduce gtid for tablet metadata) (#54326)

Signed-off-by: xiangguangyxg <[email protected]>
(cherry picked from commit f977337)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/task/CreateReplicaTask.java
#	fe/fe-core/src/main/java/com/starrocks/task/TabletTaskExecutor.java
#	gensrc/proto/lake_types.proto
#	gensrc/thrift/AgentService.thrift
@xiangguangyxg xiangguangyxg deleted the restore_snapshot_align_data_with_metadata branch December 27, 2024 08:26
wanpengfei-git pushed a commit that referenced this pull request Dec 27, 2024
…ode (part 3, introduce gtid for tablet metadata) (backport #54326) (#54450)

Signed-off-by: xiangguangyxg <[email protected]>
Co-authored-by: xiangguangyxg <[email protected]>
banmoy pushed a commit to banmoy/starrocks that referenced this pull request Dec 29, 2024
…ode (part 3, introduce gtid for tablet metadata) (StarRocks#54326)

Signed-off-by: xiangguangyxg <[email protected]>
maggie-zhu pushed a commit to maggie-zhu/starrocks that referenced this pull request Jan 6, 2025
…ode (part 3, introduce gtid for tablet metadata) (StarRocks#54326)

Signed-off-by: xiangguangyxg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

shared-data mode support backup restore though automated snapshot
4 participants