From db7767ad3febe68c4f376886d62a05bba5200f83 Mon Sep 17 00:00:00 2001 From: Sami Hiltunen Date: Wed, 15 Jul 2020 12:52:39 +0200 Subject: dataloss subcommand based on repository generations Changes dataloss subcommand to report data loss based on repository generations. This allows us to report more accurately, including how many writes a repository is behind at maximum. The report is not 100% accurate as generations map to mutator calls and some mutator calls do not indicate unreplicated writes. These are mutators are mainly for repository housekeeping and do make any changes visible to the client. The accuracy can be improved by tagging these housekeeping mutators later as such and ignoring them when it comes to incrementing the generation of a repository. Generations guarantee the repository was at least on the stored generation. As such, the tool might produce false positives in case a replication was successful but the database record failed to be updated. In case of a failover, some of the repositories reported as outdated may contain the latest changes. Since generations are only recorded for repositories that have received new mutator RPCs, this won't report data loss from repositories that have failed replication prior to the generations being introduced. --- ruby/proto/gitaly/praefect_pb.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'ruby') diff --git a/ruby/proto/gitaly/praefect_pb.rb b/ruby/proto/gitaly/praefect_pb.rb index 1ad2ce827..cd8fb9abb 100644 --- a/ruby/proto/gitaly/praefect_pb.rb +++ b/ruby/proto/gitaly/praefect_pb.rb @@ -22,15 +22,16 @@ Google::Protobuf::DescriptorPool.generated_pool.build do optional :virtual_storage, :string, 1 end add_message "gitaly.DatalossCheckResponse" do - optional :virtual_storage, :string, 1 - optional :previous_writable_primary, :string, 2 - optional :current_primary, :string, 3 - optional :is_read_only, :bool, 4 - repeated :outdated_nodes, :message, 5, "gitaly.DatalossCheckResponse.Nodes" + optional :primary, :string, 1 + repeated :repositories, :message, 2, "gitaly.DatalossCheckResponse.Repository" end - add_message "gitaly.DatalossCheckResponse.Nodes" do + add_message "gitaly.DatalossCheckResponse.Repository" do optional :relative_path, :string, 1 - repeated :nodes, :string, 2 + repeated :storages, :message, 2, "gitaly.DatalossCheckResponse.Repository.Storage" + end + add_message "gitaly.DatalossCheckResponse.Repository.Storage" do + optional :name, :string, 1 + optional :behind_by, :int64, 2 end add_message "gitaly.RepositoryReplicasRequest" do optional :repository, :message, 1, "gitaly.Repository" @@ -65,7 +66,8 @@ module Gitaly EnableWritesResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.EnableWritesResponse").msgclass DatalossCheckRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.DatalossCheckRequest").msgclass DatalossCheckResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.DatalossCheckResponse").msgclass - DatalossCheckResponse::Nodes = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.DatalossCheckResponse.Nodes").msgclass + DatalossCheckResponse::Repository = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.DatalossCheckResponse.Repository").msgclass + DatalossCheckResponse::Repository::Storage = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.DatalossCheckResponse.Repository.Storage").msgclass RepositoryReplicasRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.RepositoryReplicasRequest").msgclass RepositoryReplicasResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.RepositoryReplicasResponse").msgclass RepositoryReplicasResponse::RepositoryDetails = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.RepositoryReplicasResponse.RepositoryDetails").msgclass -- cgit v1.2.3