-
Notifications
You must be signed in to change notification settings - Fork 9
Range size tracking #420
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
Range size tracking #420
Changes from all commits
8bf4940
ff06fc1
15cb6ad
575f24d
4a6a18e
f072cc8
24d92a9
772a6b1
4360e6e
83e6a2e
05a1c3a
76fa3d1
4694818
2330266
6a2d770
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,9 @@ class BigTableHandler : public txservice::store::DataStoreHandler | |
|
|
||
| void FetchRangeSlices(txservice::FetchRangeSlicesReq *fetch_cc) override; | ||
|
|
||
| void FetchTableRangeSize( | ||
| txservice::FetchTableRangeSizeCc *fetch_cc) override; | ||
|
|
||
|
Comment on lines
+85
to
+87
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. 🧩 Analysis chain🏁 Script executed: rg -n -A 15 'BigTableHandler::FetchTableRangeSize' --type=cppRepository: eloqdata/tx_service Length of output: 1492 Fix stub implementation to properly signal unsupported operation. The stub implementation at lines 713-718 in
Set an appropriate error status on 🤖 Prompt for AI Agents |
||
| /** | ||
| * @brief Read a row from base table or skindex table in datastore with | ||
| * specified key. Caller should pass in complete primary key or skindex key. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -793,8 +793,9 @@ void FetchTableRangesCallback(void *data, | |
| for (uint32_t i = 0; i < items_size; i++) | ||
| { | ||
| scan_next_closure->GetItem(i, key, value, ts, ttl); | ||
| assert(value.size() == (sizeof(int32_t) + sizeof(uint64_t) + | ||
| sizeof(uint64_t) + sizeof(uint32_t))); | ||
| assert(value.size() == | ||
| (sizeof(int32_t) + sizeof(uint64_t) + sizeof(uint64_t) + | ||
| sizeof(uint32_t) + sizeof(int32_t))); | ||
| const char *buf = value.data(); | ||
| int32_t partition_id = *(reinterpret_cast<const int32_t *>(buf)); | ||
| buf += sizeof(partition_id); | ||
|
|
@@ -926,6 +927,45 @@ void FetchTableRangesCallback(void *data, | |
| } | ||
| } | ||
|
|
||
| void FetchRangeSizeCallback(void *data, | ||
| ::google::protobuf::Closure *closure, | ||
| DataStoreServiceClient &client, | ||
| const remote::CommonResult &result) | ||
| { | ||
| txservice::FetchTableRangeSizeCc *fetch_range_size_cc = | ||
| static_cast<txservice::FetchTableRangeSizeCc *>(data); | ||
|
|
||
| if (result.error_code() == remote::DataStoreError::KEY_NOT_FOUND) | ||
| { | ||
| fetch_range_size_cc->store_range_size_ = 0; | ||
| fetch_range_size_cc->SetFinish( | ||
| static_cast<uint32_t>(txservice::CcErrorCode::NO_ERROR)); | ||
| } | ||
| else if (result.error_code() != remote::DataStoreError::NO_ERROR) | ||
| { | ||
| LOG(ERROR) << "Fetch range size failed with error code: " | ||
| << result.error_code(); | ||
| fetch_range_size_cc->SetFinish( | ||
| static_cast<uint32_t>(txservice::CcErrorCode::DATA_STORE_ERR)); | ||
| } | ||
| else | ||
| { | ||
| ReadClosure *read_closure = static_cast<ReadClosure *>(closure); | ||
| std::string_view read_val = read_closure->Value(); | ||
| assert(read_closure->TableName() == kv_range_table_name); | ||
| assert(read_val.size() == | ||
| (sizeof(int32_t) + sizeof(uint64_t) + sizeof(uint64_t) + | ||
| sizeof(uint32_t) + sizeof(int32_t))); | ||
| const char *buf = read_val.data(); | ||
| buf += read_val.size() - sizeof(int32_t); | ||
| fetch_range_size_cc->store_range_size_ = | ||
| *reinterpret_cast<const int32_t *>(buf); | ||
|
Comment on lines
+956
to
+962
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. 🧩 Analysis chain🏁 Script executed: find . -name "data_store_service_client_closure.cpp" -type fRepository: eloqdata/tx_service Length of output: 116 🏁 Script executed: wc -l ./store_handler/data_store_service_client_closure.cppRepository: eloqdata/tx_service Length of output: 121 🏁 Script executed: sed -n '950,970p' ./store_handler/data_store_service_client_closure.cppRepository: eloqdata/tx_service Length of output: 866 🏁 Script executed: sed -n '930,975p' ./store_handler/data_store_service_client_closure.cppRepository: eloqdata/tx_service Length of output: 2006 🏁 Script executed: # Check if there's any build configuration that defines assert behavior
find . -name "CMakeLists.txt" -o -name "*.cmake" | head -5Repository: eloqdata/tx_service Length of output: 188 🏁 Script executed: # Check the CMakeLists.txt for build configuration, especially Debug vs Release handling
head -100 ./CMakeLists.txt | grep -A 5 -B 5 "NDEBUG\|assert\|Debug\|Release"Repository: eloqdata/tx_service Length of output: 45 🏁 Script executed: grep -i "ndebug\|cmake_build_type" ./CMakeLists.txt | head -20Repository: eloqdata/tx_service Length of output: 45 🏁 Script executed: # Search for similar patterns in the file - other uses of assert before reinterpret_cast
grep -n "assert.*size()" ./store_handler/data_store_service_client_closure.cppRepository: eloqdata/tx_service Length of output: 333 🏁 Script executed: # Check the other similar patterns to see if they have the same issue
sed -n '790,810p' ./store_handler/data_store_service_client_closure.cppRepository: eloqdata/tx_service Length of output: 1020 🏁 Script executed: # Check the third similar pattern at line 1009
sed -n '1005,1025p' ./store_handler/data_store_service_client_closure.cppRepository: eloqdata/tx_service Length of output: 1048 🏁 Script executed: # Let's understand where read_closure->Value() comes from - check for ReadClosure definition
grep -n "class ReadClosure\|struct ReadClosure" ./store_handler/*.cpp ./store_handler/*.hRepository: eloqdata/tx_service Length of output: 334 🏁 Script executed: sed -n '600,700p' ./store_handler/data_store_service_client_closure.hRepository: eloqdata/tx_service Length of output: 3387 🏁 Script executed: sed -n '700,800p' ./store_handler/data_store_service_client_closure.hRepository: eloqdata/tx_service Length of output: 2563 🏁 Script executed: sed -n '800,850p' ./store_handler/data_store_service_client_closure.hRepository: eloqdata/tx_service Length of output: 911 🏁 Script executed: # Check if there are any other safety checks or validations before the problematic code
sed -n '930,965p' ./store_handler/data_store_service_client_closure.cppRepository: eloqdata/tx_service Length of output: 1648 Replace The size check at line 956 relies solely on Suggested fix- assert(read_val.size() ==
- (sizeof(int32_t) + sizeof(uint64_t) + sizeof(uint64_t) +
- sizeof(uint32_t) + sizeof(int32_t)));
- const char *buf = read_val.data();
- buf += read_val.size() - sizeof(int32_t);
- fetch_range_size_cc->store_range_size_ =
- *reinterpret_cast<const int32_t *>(buf);
+ constexpr size_t kExpectedRangeMetaSize =
+ sizeof(int32_t) + sizeof(uint64_t) + sizeof(uint64_t) +
+ sizeof(uint32_t) + sizeof(int32_t);
+ if (read_val.size() != kExpectedRangeMetaSize)
+ {
+ LOG(ERROR) << "Fetch range size decode failed: unexpected value size="
+ << read_val.size();
+ fetch_range_size_cc->SetFinish(
+ static_cast<uint32_t>(txservice::CcErrorCode::DATA_STORE_ERR));
+ return;
+ }
+ const char *buf = read_val.data() + read_val.size() - sizeof(int32_t);
+ fetch_range_size_cc->store_range_size_ =
+ *reinterpret_cast<const int32_t *>(buf);Note: Similar patterns exist at lines 796 and 1009 that may need the same treatment. 🤖 Prompt for AI Agents |
||
|
|
||
| fetch_range_size_cc->SetFinish( | ||
| static_cast<uint32_t>(txservice::CcErrorCode::NO_ERROR)); | ||
| } | ||
| } | ||
|
|
||
| void FetchRangeSlicesCallback(void *data, | ||
| ::google::protobuf::Closure *closure, | ||
| DataStoreServiceClient &client, | ||
|
|
@@ -966,8 +1006,9 @@ void FetchRangeSlicesCallback(void *data, | |
| else | ||
| { | ||
| assert(read_closure->TableName() == kv_range_table_name); | ||
| assert(read_val.size() == (sizeof(int32_t) + sizeof(uint64_t) + | ||
| sizeof(uint64_t) + sizeof(uint32_t))); | ||
| assert(read_val.size() == | ||
| (sizeof(int32_t) + sizeof(uint64_t) + sizeof(uint64_t) + | ||
| sizeof(uint32_t) + sizeof(int32_t))); | ||
| const char *buf = read_val.data(); | ||
| int32_t range_partition_id = | ||
| *(reinterpret_cast<const int32_t *>(buf)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2534,6 +2534,12 @@ void EloqDS::DynamoHandler::FetchRangeSlices(FetchRangeSlicesReq *fetch_cc) | |||||||||||||||||||||
| assert(false); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| void EloqDS::DynamoHandler::FetchTableRangeSize(FetchTableRangeSizeCc *fetch_cc) | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| LOG(ERROR) << "DynamoHandler::FetchTableRangeSize not implemented"; | ||||||||||||||||||||||
| assert(false); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+2537
to
+2541
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. Do not leave Line 2540 aborts in debug and becomes a silent early return in release (assert removed), so Proposed fix void EloqDS::DynamoHandler::FetchTableRangeSize(FetchTableRangeSizeCc *fetch_cc)
{
LOG(ERROR) << "DynamoHandler::FetchTableRangeSize not implemented";
- assert(false);
+ fetch_cc->SetFinish(static_cast<int>(txservice::CcErrorCode::DATA_STORE_ERR));
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| void EloqDS::DynamoHandler::OnFetchRangeSlices( | ||||||||||||||||||||||
| const Aws::DynamoDB::DynamoDBClient *client, | ||||||||||||||||||||||
| const Aws::DynamoDB::Model::GetItemRequest &request, | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1110,6 +1110,13 @@ void RocksDBHandler::FetchRangeSlices(txservice::FetchRangeSlicesReq *fetch_cc) | |
| assert(false); | ||
| } | ||
|
|
||
| void RocksDBHandler::FetchTableRangeSize( | ||
| txservice::FetchTableRangeSizeCc *fetch_cc) | ||
| { | ||
| LOG(ERROR) << "RocksDBHandler::FetchTableRangeSize not implemented"; | ||
| assert(false); | ||
| } | ||
|
Comment on lines
+1113
to
+1118
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. Avoid process abort in Line 1117 hard-aborts ( 🤖 Prompt for AI Agents |
||
|
|
||
| bool DeleteOutOfRangeDataInternal(std::string delete_from_partition_sql, | ||
| int32_t partition_id, | ||
| const txservice::TxKey *start_k) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -346,6 +346,9 @@ class RocksDBHandler : public txservice::store::DataStoreHandler | |
|
|
||
| void FetchRangeSlices(txservice::FetchRangeSlicesReq *fetch_cc) override; | ||
|
|
||
| void FetchTableRangeSize( | ||
| txservice::FetchTableRangeSizeCc *fetch_cc) override; | ||
|
|
||
|
Comment on lines
+349
to
+351
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. 🧩 Analysis chain🏁 Script executed: rg -n -A 15 'RocksDBHandler::FetchTableRangeSize' --type=cppRepository: eloqdata/tx_service Length of output: 1396 🏁 Script executed: rg -n -A 15 'BigTableHandler::FetchTableRangeSize' --type=cppRepository: eloqdata/tx_service Length of output: 1492 Use proper error handling instead of assert(false) for unsupported operations. The current stub implementation logs an error but crashes via 🤖 Prompt for AI Agents |
||
| bool DeleteOutOfRangeDataInternal(std::string delete_from_partition_sql, | ||
| int32_t partition_id, | ||
| const txservice::TxKey *start_k); | ||
|
|
||
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.
Complete the CC request instead of aborting the process.
Line 717 uses
assert(false). That crashes debug builds, and in release builds the assert is removed sofetch_ccis never finished, which can leave the caller hanging indefinitely.Proposed fix
void EloqDS::BigTableHandler::FetchTableRangeSize( txservice::FetchTableRangeSizeCc *fetch_cc) { LOG(ERROR) << "BigTableHandler::FetchTableRangeSize not implemented"; - assert(false); + fetch_cc->SetFinish(static_cast<int>(txservice::CcErrorCode::DATA_STORE_ERR)); }📝 Committable suggestion
🤖 Prompt for AI Agents