-
Notifications
You must be signed in to change notification settings - Fork 0
Phase 7: Replication & High Availability (v2) #9
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
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e2805e0
refactor(network): use RpcHeader::HEADER_SIZE constant in server and …
poyrazK abf5182
feat(distributed): integrate Catalog with Raft for distributed DDL re…
poyrazK 41dd753
style: apply clang-format across all Phase 7 files
poyrazK f891588
style: manual multi-line and spacing fixes to match CI clang-format v…
poyrazK 761b73d
style: apply clang-format 21 to all modified files
poyrazK ecd8474
style: exhaustive manual formatting fixes for CI compliance
poyrazK 49056aa
style: fix double-space regression in struct initializations
poyrazK 123ef27
fix(network): add missing members to RpcServer header for robust shut…
poyrazK ee36704
fix(build): add log_record.cpp to CMake CORE_SOURCES
poyrazK 9be4439
fix(ci): update binary names in workflow to match project targets
poyrazK 6a1e3e1
fix(build): use BUILD_TESTS option to match CI configuration
poyrazK f33602a
test(distributed): sync tests with 12-byte RpcHeader and apply spacin…
poyrazK 5e242ff
fix(catalog): throw exception on duplicate table to satisfy unit tests
poyrazK 1438ec1
fix(build): restore server_tests and sync distributed unit tests with…
poyrazK b119709
fix(build): add BUILD_COVERAGE option and flags to CMakeLists.txt
poyrazK 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,25 +94,28 @@ QueryResult DistributedExecutor::execute(const parser::Statement& stmt, | |
| // Metadata operations (Group 0) must be routed to the Catalog Leader | ||
| std::string leader_id = cluster_manager_.get_leader(0); | ||
| auto nodes = cluster_manager_.get_coordinators(); | ||
|
|
||
| const cluster::NodeInfo* target = nullptr; | ||
| if (!leader_id.empty()) { | ||
| for (const auto& n : nodes) { | ||
| if (n.id == leader_id) { target = &n; break; } | ||
| if (n.id == leader_id) { | ||
| target = &n; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Fallback: route to first coordinator if leader unknown (leader will redirect or proxy) | ||
| if (!target && !nodes.empty()) target = &nodes[0]; | ||
|
|
||
| if (target) { | ||
| network::RpcClient client(target->address, target->cluster_port); | ||
| if (client.connect()) { | ||
| // In a full implementation, DDL would be sent as a Catalog-specific RPC | ||
| // For POC, we treat it success locally after replication initiation | ||
| } | ||
| } | ||
| return {}; | ||
| return {}; | ||
|
Comment on lines
95
to
+118
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. DDL path reports success even when no coordinator is reachable. At Line 118, the branch returns success even if 🛠️ Proposed fix- if (target) {
- network::RpcClient client(target->address, target->cluster_port);
- if (client.connect()) {
- // In a full implementation, DDL would be sent as a Catalog-specific RPC
- // For POC, we treat it success locally after replication initiation
- }
- }
- return {};
+ if (target == nullptr) {
+ QueryResult res;
+ res.set_error("No coordinator available for DDL routing");
+ return res;
+ }
+
+ network::RpcClient client(target->address, target->cluster_port);
+ if (!client.connect()) {
+ QueryResult res;
+ res.set_error("Failed to connect to coordinator leader for DDL routing");
+ return res;
+ }
+
+ // TODO: send Catalog-specific RPC and validate response.
+ return {};🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| auto data_nodes = cluster_manager_.get_data_nodes(); | ||
|
|
@@ -319,7 +322,7 @@ QueryResult DistributedExecutor::execute(const parser::Statement& stmt, | |
|
|
||
| const uint32_t shard_idx = cluster::ShardManager::compute_shard( | ||
| pk_val, static_cast<uint32_t>(data_nodes.size())); | ||
|
|
||
| // Leader-Aware Routing: Find shard leader | ||
| std::string leader_id = cluster_manager_.get_leader(shard_idx + 1); | ||
| bool found_leader = false; | ||
|
|
@@ -332,7 +335,7 @@ QueryResult DistributedExecutor::execute(const parser::Statement& stmt, | |
| } | ||
| } | ||
| } | ||
|
|
||
| if (!found_leader) target_nodes.push_back(data_nodes[shard_idx]); | ||
| } | ||
| } | ||
|
|
@@ -353,7 +356,7 @@ QueryResult DistributedExecutor::execute(const parser::Statement& stmt, | |
| if (try_extract_sharding_key(where_expr, pk_val)) { | ||
| const uint32_t shard_idx = cluster::ShardManager::compute_shard( | ||
| pk_val, static_cast<uint32_t>(data_nodes.size())); | ||
|
|
||
| // Leader-Aware Routing: Route mutations/queries to the current shard leader | ||
| std::string leader_id = cluster_manager_.get_leader(shard_idx + 1); | ||
| bool found_leader = false; | ||
|
|
||
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.
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.
Fix H1 ATX syntax for markdownlint compliance.
Line 1 is missing the required space after
#and is harder to read without spacing around&.✏️ Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)
[warning] 1-1: No space after hash on atx style heading
(MD018, no-missing-space-atx)
🤖 Prompt for AI Agents