-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Tool] Add DumpOrdinalIndex and VerifyPageChecksum meta tool. #51489
Open
wuxueyang96
wants to merge
2
commits into
StarRocks:main
Choose a base branch
from
wuxueyang96:add_meta_tools
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+115
−0
Conversation
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
std::cout << "no page offset or page size flag for verify page checksum" << std::endl; | ||
return -1; | ||
} | ||
verify_page_checksum(FLAGS_file, {FLAGS_page_offset, FLAGS_page_size}); | ||
} else if (FLAGS_operation == "show_segment_footer") { | ||
if (FLAGS_file == "") { | ||
std::cout << "no file flag for show dict" << std::endl; |
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.
The most risky bug in this code is:
Undefined PagePointer
in verify_page_checksum
.
You can modify the code like this:
// Add this line at the top with other includes
#include "runtime/memory/page_pointer.h"
// Ensure that your verify_page_checksum and meta_tool_main functions are as follows
void verify_page_checksum(const std::string& file_name, const starrocks::PagePointer& page_pointer) {
auto res = starrocks::FileSystem::Default()->new_random_access_file(file_name);
if (!res.ok()) {
std::cout << "open file failed: " << res.status() << std::endl;
return;
}
auto input_file = std::move(res).value();
const uint32_t page_size = page_pointer.size;
std::unique_ptr<char[]> page(new char[page_size + starrocks::Column::APPEND_OVERFLOW_MAX_SIZE]);
Slice page_slice(page.get(), page_size);
input_file->read_at_fully(page_pointer.offset, page_slice.data, page_slice.size);
uint32_t expect = starrocks::decode_fixed32_le((uint8_t*)page_slice.data + page_slice.size - 4);
uint32_t actual = starrocks::crc32c::Value(page_slice.data, page_slice.size - 4);
if (expect != actual) {
std::cout << "Bad page: checksum mismatch (actual=" << actual << " vs expect=" << expect << ")";
return;
}
}
int meta_tool_main(int argc, char** argv) {
// Add the below flags check before entering each condition
if (FLAGS_operation == "dump_ordinal_index") {
if (FLAGS_file == "") {
std::cout << "no file flag for dump ordinal index" << std::endl;
return -1;
}
if (FLAGS_column_index == -1) {
std::cout << "no column_index flag for dump ordinal index" << std::endl;
return -1;
}
dump_ordinal_index(FLAGS_file, FLAGS_column_index);
} else if (FLAGS_operation == "verify_page_checksum") {
if (FLAGS_file == "") {
std::cout << "no file flag for verify page checksum" << std::endl;
return -1;
}
if (FLAGS_page_offset == -1 || FLAGS_page_size == -1) {
std::cout << "no page offset or page size flag for verify page checksum" << std::endl;
return -1;
}
verify_page_checksum(FLAGS_file, {FLAGS_page_offset, FLAGS_page_size});
}
// ...rest of the function
}
wuxueyang96
changed the title
Add DumpOrdinalIndex and VerifyPageChecksum meta tool
[Tool] Add DumpOrdinalIndex and VerifyPageChecksum meta tool.
Oct 8, 2024
Signed-off-by: 枢木 <[email protected]>
wuxueyang96
force-pushed
the
add_meta_tools
branch
from
October 14, 2024 08:08
779841b
to
fd10084
Compare
Signed-off-by: 枢木 <[email protected]>
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[BE Incremental Coverage Report]❌ fail : 0 / 71 (00.00%) file detail
|
miomiocat
approved these changes
Oct 14, 2024
meegoo
approved these changes
Nov 20, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why I'm doing:
What I'm doing:
Add two tools to verify a segment's ordinal index is correct. It can be used like below:
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: