-
Notifications
You must be signed in to change notification settings - Fork 606
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
schemeshard: reject operations with too big local tx commit #6760
Merged
ijon
merged 1 commit into
ydb-platform:main
from
ijon:fix-schemeshard-reject-too-massive-operations
Jul 18, 2024
Merged
Changes from all commits
Commits
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 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 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 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
113 changes: 113 additions & 0 deletions
113
ydb/core/tx/schemeshard/ut_base/ut_commit_redo_limit.cpp
This file contains 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 |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#include <ydb/core/tx/schemeshard/ut_helpers/helpers.h> | ||
|
||
using namespace NKikimr; | ||
using namespace NSchemeShard; | ||
using namespace NSchemeShardUT_Private; | ||
|
||
Y_UNIT_TEST_SUITE(TSchemeShardCheckProposeSize) { | ||
|
||
//TODO: can't check all operations as many of them do not implement | ||
// TSubOperation::AbortPropose() properly and will abort. | ||
|
||
Y_UNIT_TEST(CopyTable) { | ||
TTestBasicRuntime runtime; | ||
TTestEnv env(runtime); | ||
|
||
// Take control over MaxCommitRedoMB ICB setting. | ||
// Drop down its min-value limit to be able to set it as low as test needs. | ||
TControlWrapper MaxCommitRedoMB; | ||
{ | ||
runtime.GetAppData().Icb->RegisterSharedControl(MaxCommitRedoMB, "TabletControls.MaxCommitRedoMB"); | ||
MaxCommitRedoMB.Reset(200, 1, 4096); | ||
} | ||
|
||
ui64 txId = 100; | ||
|
||
TestCreateTable(runtime, ++txId, "/MyRoot", R"( | ||
Name: "table" | ||
Columns { Name: "key" Type: "Uint64"} | ||
Columns { Name: "value" Type: "Utf8"} | ||
KeyColumnNames: ["key"] | ||
)"); | ||
env.TestWaitNotification(runtime, txId); | ||
|
||
// 1. Set MaxCommitRedoMB to 1 and try to create table. | ||
// | ||
// (Check at the operation's Propose tests commit redo size against (MaxCommitRedoMB - 1) | ||
// to give 1MB leeway to executer/tablet inner stuff to may be do "something extra". | ||
// So MaxCommitRedoMB = 1 means effective 0 for the size of operation's commit.) | ||
{ | ||
MaxCommitRedoMB = 1; | ||
AsyncCopyTable(runtime, ++txId, "/MyRoot", "table-copy", "/MyRoot/table"); | ||
TestModificationResults(runtime, txId, | ||
{{NKikimrScheme::StatusSchemeError, "local tx commit redo size generated by IgniteOperation() is more than allowed limit"}} | ||
); | ||
env.TestWaitNotification(runtime, txId); | ||
} | ||
|
||
// 2. Set MaxCommitRedoMB back to high value and try again. | ||
{ | ||
MaxCommitRedoMB = 200; | ||
AsyncCopyTable(runtime, ++txId, "/MyRoot", "table-copy", "/MyRoot/table"); | ||
env.TestWaitNotification(runtime, txId); | ||
} | ||
} | ||
|
||
Y_UNIT_TEST(CopyTables) { | ||
TTestBasicRuntime runtime; | ||
TTestEnv env(runtime); | ||
|
||
// Take control over MaxCommitRedoMB ICB setting. | ||
// Drop down its min-value limit to be able to set it as low as test needs. | ||
TControlWrapper MaxCommitRedoMB; | ||
{ | ||
runtime.GetAppData().Icb->RegisterSharedControl(MaxCommitRedoMB, "TabletControls.MaxCommitRedoMB"); | ||
MaxCommitRedoMB.Reset(200, 1, 4096); | ||
} | ||
|
||
const ui64 tables = 100; | ||
const ui64 shardsPerTable = 1; | ||
|
||
ui64 txId = 100; | ||
|
||
for (ui64 i : xrange(tables)) { | ||
TestCreateTable(runtime, ++txId, "/MyRoot", Sprintf( | ||
R"( | ||
Name: "table-%lu" | ||
Columns { Name: "key" Type: "Uint64"} | ||
Columns { Name: "value" Type: "Utf8"} | ||
KeyColumnNames: ["key"] | ||
UniformPartitionsCount: %lu | ||
)", | ||
i, | ||
shardsPerTable | ||
)); | ||
env.TestWaitNotification(runtime, txId); | ||
} | ||
|
||
auto testCopyTables = [](auto& runtime, ui64 txId, ui64 tables) { | ||
TVector<TEvTx*> schemeTxs; | ||
for (ui64 i : xrange(tables)) { | ||
schemeTxs.push_back(CopyTableRequest(txId, "/MyRoot", Sprintf("table-%lu-copy", i), Sprintf("/MyRoot/table-%lu", i))); | ||
} | ||
AsyncSend(runtime, TTestTxConfig::SchemeShard, CombineSchemeTransactions(schemeTxs)); | ||
}; | ||
|
||
// 1. Set MaxCommitRedoMB to 1 and try to copy tables. | ||
{ | ||
MaxCommitRedoMB = 1; | ||
testCopyTables(runtime, ++txId, tables); | ||
TestModificationResults(runtime, txId, | ||
{{NKikimrScheme::StatusSchemeError, "local tx commit redo size generated by IgniteOperation() is more than allowed limit"}} | ||
); | ||
} | ||
|
||
// 2. Set MaxCommitRedoMB back to high value and try again. | ||
{ | ||
MaxCommitRedoMB = 200; | ||
testCopyTables(runtime, ++txId, tables); | ||
TestModificationResults(runtime, txId, {{NKikimrScheme::StatusAccepted}}); | ||
} | ||
} | ||
|
||
} |
This file contains 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 |
---|---|---|
|
@@ -27,6 +27,7 @@ SRCS( | |
ut_base.cpp | ||
ut_info_types.cpp | ||
ut_table_pg_types.cpp | ||
ut_commit_redo_limit.cpp | ||
) | ||
|
||
END() |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Смущает, что в ApplyOnExecute передаётся txc. Я вроде бы перепроверил, и там в базу пишется только в некоторых случаях, и по идее в dependencies мы много не должны сохранить, в будущем надеюсь мы сделаем чтобы у нас всё это оптимистично в базу добавлялось и разночтений не возникало...