From 8a71be5e4472bf788248aa061a7ca56d6eda0266 Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Mon, 30 Jun 2025 09:34:54 +0100 Subject: [PATCH 1/9] Add cluster support (#228) Introduce cluster support for TypeDB 3.x, featuring server replicas and the new version message. Remove database replicas. Instead, add server replicas (by extending the usual `Server` message) with a similar set of fields. Instead of adding a `is_primary` flag, introduce an extensible enum `ReplicaType` for more granular split between primary and supporting nodes. To reduce the network overhead, this new information is provided in the initial server's connection response. --- proto/typedb_service/typedb_service.proto | 3 +++ 1 file changed, 3 insertions(+) diff --git a/proto/typedb_service/typedb_service.proto b/proto/typedb_service/typedb_service.proto index 03d6648..f799d94 100644 --- a/proto/typedb_service/typedb_service.proto +++ b/proto/typedb_service/typedb_service.proto @@ -31,6 +31,9 @@ service TypeDB { // Server API rpc server_version (Server.Version.Req) returns (Server.Version.Res); + // Server API + rpc server_version (Server.Version.Req) returns (Server.Version.Res); + // User Manager API rpc users_get (UserManager.Get.Req) returns (UserManager.Get.Res); rpc users_all (UserManager.All.Req) returns (UserManager.All.Res); From c76f691563fa9b99d5880037681a0139b248515b Mon Sep 17 00:00:00 2001 From: Ganeshwara Hananda Date: Wed, 9 Jul 2025 13:51:43 +0100 Subject: [PATCH 2/9] Move raft peering protocol to this repo --- grpc/rust/build.rs | 2 ++ proto/raft-peering-service.proto | 9 +++++++++ proto/raft-peering.proto | 12 ++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 proto/raft-peering-service.proto create mode 100644 proto/raft-peering.proto diff --git a/grpc/rust/build.rs b/grpc/rust/build.rs index 8ba15f0..9cb6c97 100644 --- a/grpc/rust/build.rs +++ b/grpc/rust/build.rs @@ -24,6 +24,8 @@ fn main() -> std::io::Result<()> { "../../proto/typedb_service/typedb_service.proto", "../../proto/typedb_service/user.proto", "../../proto/version.proto", + "../../proto/raft-peering.proto", + "../../proto/raft-peering-service.proto", ]; tonic_build::configure() diff --git a/proto/raft-peering-service.proto b/proto/raft-peering-service.proto new file mode 100644 index 0000000..e87a8e0 --- /dev/null +++ b/proto/raft-peering-service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +import "proto/raft-peering.proto"; + +package typedb.protocol; + +service RaftPeering { + rpc Peering(PeeringRequest) returns (PeeringResponse); +} \ No newline at end of file diff --git a/proto/raft-peering.proto b/proto/raft-peering.proto new file mode 100644 index 0000000..33a1add --- /dev/null +++ b/proto/raft-peering.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package typedb.protocol; + +message PeeringRequest { + uint64 from_id = 1; + string from_address = 2; + bytes message = 3; +} + +message PeeringResponse { +} From 5a08f7761904b02e893178c8715cd6764c91fbdd Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Thu, 14 Aug 2025 14:47:42 +0100 Subject: [PATCH 3/9] Split protocol into 3 separate services (#230) Split the protocol into 3 services: * TypeDBService (contains common TypeDB logic): server, database, user, and transaction management, etc. * TypeDBClusteringService (contains TypeDB logic regarding clustering): replica registration, server status. * RaftService (contains Raft logic): replication operations. Split the old RaftPeeringService into TypeDBClusteringService and RaftService. Move separate services and their implementation files into separate subpackages. Rename methods. Introduce `ServersGet` method for single server status retrieval. Introduce `registration` method to verify the replica registration operation before submitting it to Raft. --- grpc/nodejs/BUILD | 4 ++++ grpc/rust/build.rs | 2 -- proto/BUILD | 3 +++ proto/raft-peering-service.proto | 9 --------- proto/raft-peering.proto | 12 ------------ proto/typedb_clustering_service/BUILD | 2 +- proto/typedb_service/BUILD | 2 +- 7 files changed, 9 insertions(+), 25 deletions(-) delete mode 100644 proto/raft-peering-service.proto delete mode 100644 proto/raft-peering.proto diff --git a/grpc/nodejs/BUILD b/grpc/nodejs/BUILD index 4db3294..000003e 100644 --- a/grpc/nodejs/BUILD +++ b/grpc/nodejs/BUILD @@ -50,7 +50,11 @@ ts_grpc_compile( "//proto/typedb_service:transaction-proto", "//proto/typedb_service:typedb-service", "//proto/typedb_service:user-proto", +<<<<<<< HEAD ], +======= + ] +>>>>>>> 55ed142 (Split protocol into 3 separate services (#230)) ) ts_project( diff --git a/grpc/rust/build.rs b/grpc/rust/build.rs index 9cb6c97..8ba15f0 100644 --- a/grpc/rust/build.rs +++ b/grpc/rust/build.rs @@ -24,8 +24,6 @@ fn main() -> std::io::Result<()> { "../../proto/typedb_service/typedb_service.proto", "../../proto/typedb_service/user.proto", "../../proto/version.proto", - "../../proto/raft-peering.proto", - "../../proto/raft-peering-service.proto", ]; tonic_build::configure() diff --git a/proto/BUILD b/proto/BUILD index 3b6d63b..0b61503 100644 --- a/proto/BUILD +++ b/proto/BUILD @@ -17,8 +17,11 @@ proto_library( filegroup( name = "proto-raw-buffers", srcs = [ +<<<<<<< HEAD "//proto/typedb_service:analyze.proto", "//proto/typedb_service:analyzed-conjunction.proto", +======= +>>>>>>> 55ed142 (Split protocol into 3 separate services (#230)) "//proto/typedb_service:answer.proto", "//proto/typedb_service:concept.proto", "//proto/typedb_service:connection.proto", diff --git a/proto/raft-peering-service.proto b/proto/raft-peering-service.proto deleted file mode 100644 index e87a8e0..0000000 --- a/proto/raft-peering-service.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -import "proto/raft-peering.proto"; - -package typedb.protocol; - -service RaftPeering { - rpc Peering(PeeringRequest) returns (PeeringResponse); -} \ No newline at end of file diff --git a/proto/raft-peering.proto b/proto/raft-peering.proto deleted file mode 100644 index 33a1add..0000000 --- a/proto/raft-peering.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; - -package typedb.protocol; - -message PeeringRequest { - uint64 from_id = 1; - string from_address = 2; - bytes message = 3; -} - -message PeeringResponse { -} diff --git a/proto/typedb_clustering_service/BUILD b/proto/typedb_clustering_service/BUILD index 4a5caf0..c3da7cf 100644 --- a/proto/typedb_clustering_service/BUILD +++ b/proto/typedb_clustering_service/BUILD @@ -14,7 +14,7 @@ proto_library( ], ) -proto_library( +proto/typedb_service/BUILDproto_library( name = "typedb-clustering-proto", srcs = ["typedb_clustering.proto"], deps = [ diff --git a/proto/typedb_service/BUILD b/proto/typedb_service/BUILD index 7246b15..e7b860c 100644 --- a/proto/typedb_service/BUILD +++ b/proto/typedb_service/BUILD @@ -131,4 +131,4 @@ checkstyle_test( size = "small", include = glob(["*"]), license_type = "mpl-header", -) +) \ No newline at end of file From d98b8eacb4451a7cf9afc8943095f6840c939c22 Mon Sep 17 00:00:00 2001 From: Ganeshwara Hananda Date: Fri, 24 Oct 2025 14:26:58 +0100 Subject: [PATCH 4/9] Add protobuf schema for Raft's 'state mutation request' (#232) Add protobuf schema for Raft's 'state mutation request'. The schema defines how the data is transported over the network and stored in the Raft log. - Add a protobuf definition for State Mutation Request - Create a mock RPC endpoint to handle that message as a hack to get the code generator to work --- grpc/nodejs/BUILD | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grpc/nodejs/BUILD b/grpc/nodejs/BUILD index 000003e..ca74ac7 100644 --- a/grpc/nodejs/BUILD +++ b/grpc/nodejs/BUILD @@ -50,11 +50,15 @@ ts_grpc_compile( "//proto/typedb_service:transaction-proto", "//proto/typedb_service:typedb-service", "//proto/typedb_service:user-proto", +<<<<<<< HEAD <<<<<<< HEAD ], ======= ] >>>>>>> 55ed142 (Split protocol into 3 separate services (#230)) +======= + ], +>>>>>>> ee7a259 (Add protobuf schema for Raft's 'state mutation request' (#232)) ) ts_project( From 26139fa0fb4ef34a03ea63f7fc4db05e71e393bd Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Mon, 17 Nov 2025 16:40:55 +0000 Subject: [PATCH 5/9] Split raft services requests to categories mirroring TypeDB service and optionalize Server message --- proto/raft_service/request.proto | 87 ++++++++++++++++++++++++------- proto/typedb_service/server.proto | 6 +-- 2 files changed, 71 insertions(+), 22 deletions(-) diff --git a/proto/raft_service/request.proto b/proto/raft_service/request.proto index 2296a36..c487ba7 100644 --- a/proto/raft_service/request.proto +++ b/proto/raft_service/request.proto @@ -10,8 +10,9 @@ message Request { oneof request { Load load = 1; DatabaseManager database_manager = 2; - DatabaseCommit database_commit = 3; + Database database = 3; UserManager user_manager = 4; + User user = 5; } message Load {} @@ -23,21 +24,42 @@ message Request { GetUnrestricted get_unrestricted = 3; Create create = 4; CreateUnrestricted create_unrestricted = 5; - Delete delete = 6; } message All {} - message Get { string name = 1; } - message GetUnrestricted { string name = 1; } - message Create { string name = 1; } - message CreateUnrestricted { string name = 1; } - message Delete { string name = 1; } + + message Get { + string name = 1; + } + + message GetUnrestricted { + string name = 1; + } + + message Create { + string name = 1; + } + + message CreateUnrestricted { + string name = 1; + } } - message DatabaseCommit { - oneof database_commit { - SchemaCommit schema = 1; - DataCommit data = 2; + message Database { + oneof database { + Schema schema = 1; + TypeSchema type_schema = 2; + SchemaCommit schema_commit = 3; + DataCommit data_commit = 4; + Delete delete = 5; + } + + message Schema { + string name = 1; + } + + message TypeSchema { + string name = 1; } message SchemaCommit { @@ -49,6 +71,10 @@ message Request { string name = 1; bytes commit_record = 2; } + + message Delete { + string name = 1; + } } message UserManager { @@ -57,16 +83,39 @@ message Request { Get get = 2; Contains contains = 3; Create create = 4; - Update update = 5; - Delete delete = 6; } - message All { string accessor = 1; } - message Get { string name = 1; string accessor = 2; } - message Contains { string name = 1; } - message Create { bytes commit_record = 1; } - message Update { bytes commit_record = 1; } - message Delete { bytes commit_record = 1; } + message All { + string accessor = 1; + } + + message Get { + string name = 1; + string accessor = 2; + } + + message Contains { + string name = 1; + } + + message Create { + bytes commit_record = 1; + } + } + + message User { + oneof user { + Update update = 1; + Delete delete = 2; + } + + message Update { + bytes commit_record = 1; + } + + message Delete { + bytes commit_record = 1; + } } } diff --git a/proto/typedb_service/server.proto b/proto/typedb_service/server.proto index 695a409..f75f5f3 100644 --- a/proto/typedb_service/server.proto +++ b/proto/typedb_service/server.proto @@ -38,13 +38,13 @@ message ServerManager { } message Server { - string address = 1; + optional string address = 1; optional ReplicaStatus replica_status = 2; message ReplicaStatus { uint64 replica_id = 1; - ReplicaType replica_type = 2; - uint64 term = 3; + optional ReplicaType replica_type = 2; + optional uint64 term = 3; enum ReplicaType { Primary = 0; From 7ea7630360fe23039adf01f7fa47bf890b03c5de Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Mon, 17 Nov 2025 17:48:16 +0000 Subject: [PATCH 6/9] Add Contains to Database request, reorder things --- proto/raft_service/request.proto | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/proto/raft_service/request.proto b/proto/raft_service/request.proto index c487ba7..4413243 100644 --- a/proto/raft_service/request.proto +++ b/proto/raft_service/request.proto @@ -20,14 +20,19 @@ message Request { message DatabaseManager { oneof database_manager { All all = 1; - Get get = 2; - GetUnrestricted get_unrestricted = 3; - Create create = 4; - CreateUnrestricted create_unrestricted = 5; + Contains contains = 2; + Get get = 3; + GetUnrestricted get_unrestricted = 4; + Create create = 5; + CreateUnrestricted create_unrestricted = 6; } message All {} + message Contains { + string name = 1; + } + message Get { string name = 1; } @@ -35,7 +40,6 @@ message Request { message GetUnrestricted { string name = 1; } - message Create { string name = 1; } @@ -80,8 +84,8 @@ message Request { message UserManager { oneof user_manager { All all = 1; - Get get = 2; - Contains contains = 3; + Contains contains = 2; + Get get = 3; Create create = 4; } @@ -89,13 +93,13 @@ message Request { string accessor = 1; } - message Get { + message Contains { string name = 1; - string accessor = 2; } - message Contains { + message Get { string name = 1; + string accessor = 2; } message Create { @@ -118,4 +122,3 @@ message Request { } } } - From 41b1177231148a7fc2d6ad536f51a6279da4d9a3 Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Mon, 17 Nov 2025 18:30:45 +0000 Subject: [PATCH 7/9] Add accessor to user contains proto --- proto/raft_service/request.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/proto/raft_service/request.proto b/proto/raft_service/request.proto index 4413243..ff88beb 100644 --- a/proto/raft_service/request.proto +++ b/proto/raft_service/request.proto @@ -95,6 +95,7 @@ message Request { message Contains { string name = 1; + string accessor = 2; } message Get { From fdb613a588b7b6ec86a58c23a3108533299e7ca7 Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Wed, 19 Nov 2025 14:53:38 +0000 Subject: [PATCH 8/9] After-rebase magic --- grpc/nodejs/BUILD | 8 -------- proto/BUILD | 3 --- proto/typedb_clustering_service/BUILD | 2 +- proto/typedb_service/typedb_service.proto | 4 ---- 4 files changed, 1 insertion(+), 16 deletions(-) diff --git a/grpc/nodejs/BUILD b/grpc/nodejs/BUILD index ca74ac7..4db3294 100644 --- a/grpc/nodejs/BUILD +++ b/grpc/nodejs/BUILD @@ -50,15 +50,7 @@ ts_grpc_compile( "//proto/typedb_service:transaction-proto", "//proto/typedb_service:typedb-service", "//proto/typedb_service:user-proto", -<<<<<<< HEAD -<<<<<<< HEAD ], -======= - ] ->>>>>>> 55ed142 (Split protocol into 3 separate services (#230)) -======= - ], ->>>>>>> ee7a259 (Add protobuf schema for Raft's 'state mutation request' (#232)) ) ts_project( diff --git a/proto/BUILD b/proto/BUILD index 0b61503..3b6d63b 100644 --- a/proto/BUILD +++ b/proto/BUILD @@ -17,11 +17,8 @@ proto_library( filegroup( name = "proto-raw-buffers", srcs = [ -<<<<<<< HEAD "//proto/typedb_service:analyze.proto", "//proto/typedb_service:analyzed-conjunction.proto", -======= ->>>>>>> 55ed142 (Split protocol into 3 separate services (#230)) "//proto/typedb_service:answer.proto", "//proto/typedb_service:concept.proto", "//proto/typedb_service:connection.proto", diff --git a/proto/typedb_clustering_service/BUILD b/proto/typedb_clustering_service/BUILD index c3da7cf..4a5caf0 100644 --- a/proto/typedb_clustering_service/BUILD +++ b/proto/typedb_clustering_service/BUILD @@ -14,7 +14,7 @@ proto_library( ], ) -proto/typedb_service/BUILDproto_library( +proto_library( name = "typedb-clustering-proto", srcs = ["typedb_clustering.proto"], deps = [ diff --git a/proto/typedb_service/typedb_service.proto b/proto/typedb_service/typedb_service.proto index f799d94..2dec0f6 100644 --- a/proto/typedb_service/typedb_service.proto +++ b/proto/typedb_service/typedb_service.proto @@ -31,9 +31,6 @@ service TypeDB { // Server API rpc server_version (Server.Version.Req) returns (Server.Version.Res); - // Server API - rpc server_version (Server.Version.Req) returns (Server.Version.Res); - // User Manager API rpc users_get (UserManager.Get.Req) returns (UserManager.Get.Res); rpc users_all (UserManager.All.Req) returns (UserManager.All.Res); @@ -62,5 +59,4 @@ service TypeDB { // requests and responses back-and-forth. The first transaction client message must // be {Transaction.Open.Req}. Closing the stream closes the transaction. rpc transaction (stream Transaction.Client) returns (stream Transaction.Server); - } From fdda883a7de86c7562b84dede94b149be81ea54c Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Wed, 19 Nov 2025 14:54:28 +0000 Subject: [PATCH 9/9] Empty lines --- proto/typedb_service/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/typedb_service/BUILD b/proto/typedb_service/BUILD index e7b860c..7246b15 100644 --- a/proto/typedb_service/BUILD +++ b/proto/typedb_service/BUILD @@ -131,4 +131,4 @@ checkstyle_test( size = "small", include = glob(["*"]), license_type = "mpl-header", -) \ No newline at end of file +)