- Notifications
You must be signed in to change notification settings - Fork 727
Import changefeed's consumers from s3 #14780
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
Merged
stanislav-shchetinin merged 11 commits into ydb-platform:main from stanislav-shchetinin:import=s3-consumers-2 Feb 28, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits Select commit Hold shift + click to select a range
e9e567a try
stanislav-shchetinin 67b9b51 fix paths
stanislav-shchetinin 0dbee4f test
stanislav-shchetinin 26200f5 v1 working version
stanislav-shchetinin 69c94d0 set important
stanislav-shchetinin 68ee17d try fix reboot
stanislav-shchetinin ece389c timeout
stanislav-shchetinin 00e91e0 StreamImplPathId
stanislav-shchetinin 7175871 fix review
stanislav-shchetinin ea311fc removed pq_schema_actor.h
stanislav-shchetinin 28eb930 SetReturnPartitioningInfo(false)
stanislav-shchetinin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -541,6 +541,21 @@ struct TSchemeShard::TImport::TTxProgress: public TSchemeShard::TXxport::TTxBase | |
| Send(Self->SelfId(), CreateChangefeedPropose(Self, txId, item)); | ||
| } | ||
| | ||
| void CreateConsumers(TImportInfo::TPtr importInfo, ui32 itemIdx, TTxId txId) { | ||
| Y_ABORT_UNLESS(itemIdx < importInfo->Items.size()); | ||
| auto& item = importInfo->Items.at(itemIdx); | ||
| item.SubState = ESubState::Proposed; | ||
| | ||
| LOG_I("TImport::TTxProgress: CreateConsumers propose" | ||
| << ": info# " << importInfo->ToString() | ||
| << ", item# " << item.ToString(itemIdx) | ||
| << ", txId# " << txId); | ||
| | ||
| Y_ABORT_UNLESS(item.WaitTxId == InvalidTxId); | ||
| | ||
| Send(Self->SelfId(), CreateConsumersPropose(Self, txId, item)); | ||
| } | ||
| | ||
| void AllocateTxId(TImportInfo::TPtr importInfo, ui32 itemIdx) { | ||
| Y_ABORT_UNLESS(itemIdx < importInfo->Items.size()); | ||
| auto& item = importInfo->Items.at(itemIdx); | ||
| | @@ -622,6 +637,26 @@ struct TSchemeShard::TImport::TTxProgress: public TSchemeShard::TXxport::TTxBase | |
| return path->LastTxId; | ||
| } | ||
| | ||
| TTxId GetActiveCreateConsumerTxId(TImportInfo::TPtr importInfo, ui32 itemIdx) { | ||
| Y_ABORT_UNLESS(itemIdx < importInfo->Items.size()); | ||
| const auto& item = importInfo->Items.at(itemIdx); | ||
| | ||
| Y_ABORT_UNLESS(item.State == EState::CreateChangefeed); | ||
| Y_ABORT_UNLESS(item.ChangefeedState == TImportInfo::TItem::EChangefeedState::CreateConsumers); | ||
| Y_ABORT_UNLESS(item.StreamImplPathId); | ||
| | ||
| if (!Self->PathsById.contains(item.StreamImplPathId)) { | ||
| return InvalidTxId; | ||
| } | ||
| | ||
| auto path = Self->PathsById.at(item.StreamImplPathId); | ||
| if (path->PathState != NKikimrSchemeOp::EPathStateAlter) { | ||
| return InvalidTxId; | ||
| } | ||
| | ||
| return path->LastTxId; | ||
| } | ||
| | ||
| static TString MakeIndexBuildUid(TImportInfo::TPtr importInfo, ui32 itemIdx) { | ||
| Y_ABORT_UNLESS(itemIdx < importInfo->Items.size()); | ||
| const auto& item = importInfo->Items.at(itemIdx); | ||
| | @@ -816,10 +851,6 @@ struct TSchemeShard::TImport::TTxProgress: public TSchemeShard::TXxport::TTxBase | |
| TTxId txId = InvalidTxId; | ||
| | ||
| switch (item.State) { | ||
| case EState::CreateChangefeed: | ||
| txId = GetActiveCreateChangefeedTxId(importInfo, itemIdx); | ||
| break; | ||
| | ||
| case EState::Transferring: | ||
| if (!CancelTransferring(importInfo, itemIdx)) { | ||
| txId = GetActiveRestoreTxId(importInfo, itemIdx); | ||
| | @@ -1045,7 +1076,11 @@ struct TSchemeShard::TImport::TTxProgress: public TSchemeShard::TXxport::TTxBase | |
| break; | ||
| | ||
| case EState::CreateChangefeed: | ||
| CreateChangefeed(importInfo, i, txId); | ||
| if (item.ChangefeedState == TImportInfo::TItem::EChangefeedState::CreateChangefeed) { | ||
| CreateChangefeed(importInfo, i, txId); | ||
| } else { | ||
| CreateConsumers(importInfo, i, txId); | ||
| } | ||
| itemIdx = i; | ||
| break; | ||
| | ||
| | @@ -1109,11 +1144,30 @@ struct TSchemeShard::TImport::TTxProgress: public TSchemeShard::TXxport::TTxBase | |
| } else if (item.State == EState::Transferring) { | ||
| txId = GetActiveRestoreTxId(importInfo, itemIdx); | ||
| } else if (item.State == EState::CreateChangefeed) { | ||
| txId = GetActiveCreateChangefeedTxId(importInfo, itemIdx); | ||
| if (item.ChangefeedState == TImportInfo::TItem::EChangefeedState::CreateChangefeed) { | ||
| txId = GetActiveCreateChangefeedTxId(importInfo, itemIdx); | ||
| } else { | ||
| txId = GetActiveCreateConsumerTxId(importInfo, itemIdx); | ||
| } | ||
| | ||
| } | ||
| } | ||
| | ||
| if (txId == InvalidTxId) { | ||
| | ||
| if (record.GetStatus() == NKikimrScheme::StatusAlreadyExists && item.State == EState::CreateChangefeed) { | ||
| Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Хорошо было бы на эту логику тест добавить | ||
| if (item.ChangefeedState == TImportInfo::TItem::EChangefeedState::CreateChangefeed) { | ||
| item.ChangefeedState = TImportInfo::TItem::EChangefeedState::CreateConsumers; | ||
| AllocateTxId(importInfo, itemIdx); | ||
| } else if (++item.NextChangefeedIdx < item.Changefeeds.GetChangefeeds().size()) { | ||
| item.ChangefeedState = TImportInfo::TItem::EChangefeedState::CreateChangefeed; | ||
| AllocateTxId(importInfo, itemIdx); | ||
| } else { | ||
| item.State = EState::Done; | ||
| } | ||
| return; | ||
| } | ||
| | ||
| return CancelAndPersist(db, importInfo, itemIdx, record.GetReason(), "unhappy propose"); | ||
| } | ||
| | ||
| | @@ -1290,7 +1344,11 @@ struct TSchemeShard::TImport::TTxProgress: public TSchemeShard::TXxport::TTxBase | |
| break; | ||
| | ||
| case EState::CreateChangefeed: | ||
| if (++item.NextChangefeedIdx < item.Changefeeds.GetChangefeeds().size()) { | ||
| if (item.ChangefeedState == TImportInfo::TItem::EChangefeedState::CreateChangefeed) { | ||
| item.ChangefeedState = TImportInfo::TItem::EChangefeedState::CreateConsumers; | ||
| AllocateTxId(importInfo, itemIdx); | ||
| } else if (++item.NextChangefeedIdx < item.Changefeeds.GetChangefeeds().size()) { | ||
| item.ChangefeedState = TImportInfo::TItem::EChangefeedState::CreateChangefeed; | ||
| AllocateTxId(importInfo, itemIdx); | ||
| } else { | ||
| item.State = EState::Done; | ||
| | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.