diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-08-20 09:10:28 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-08-20 11:04:41 +0300 |
commit | d9179f7298abfbdb171372a1d8bc587f5e43b98c (patch) | |
tree | 48e58eecfca48b22bafa8148cfdedefe605fc5f4 | |
parent | 56251315578cd17c0ceebcb911e8d3ddb159afca (diff) |
proto: Relabel `smarthttp.InfoRefsReceivePack` as accessor
The `smarthttp.InfoRefsReceivePack` RPC is currently labelled as
mutator. Taking a closer look at it, there is no way it can change any
objects in the repo though, as it will always either spawn `git
receive-pack --stateless-rpc --advertise-refs` or `git upload-pack
--stateless-rpc --advertise-refs`. While git-receive-pack(1) may modify
the repo, it won't ever do so with the `--advertise-refs` flag, as it
will cause the command to only advertise references and then exit
immediately afterwards.
As the RPC is called in quick succession with `smarthttp.PostUploadPack`
in case a user performs a push, the first call to InfoRefsReceivePack
would've increased the repository generation and caused replication jobs
to be created. As a result, when PostUploadPack gets invoked it is
likely that secondaries will be treated as out-of-date as replication
jobs usually weren't processed yet. This in turn breaks transactions, as
we will now only add the primary to any transaction for all pushes via
smarthttp.
So let's relabel the RPC as an accessor to avoid replication when it's
called and fix the described issue.
-rw-r--r-- | changelogs/unreleased/pks-inforefs-accessor.yml | 5 | ||||
-rw-r--r-- | internal/praefect/protoregistry/protoregistry_test.go | 2 | ||||
-rw-r--r-- | proto/go/gitalypb/smarthttp.pb.go | 70 | ||||
-rw-r--r-- | proto/smarthttp.proto | 6 | ||||
-rw-r--r-- | ruby/proto/gitaly/smarthttp_services_pb.rb | 4 |
5 files changed, 46 insertions, 41 deletions
diff --git a/changelogs/unreleased/pks-inforefs-accessor.yml b/changelogs/unreleased/pks-inforefs-accessor.yml new file mode 100644 index 000000000..79f16621f --- /dev/null +++ b/changelogs/unreleased/pks-inforefs-accessor.yml @@ -0,0 +1,5 @@ +--- +title: Relabel smarthttp.InfoRefsReceivePack as accessor +merge_request: 2487 +author: +type: fixed diff --git a/internal/praefect/protoregistry/protoregistry_test.go b/internal/praefect/protoregistry/protoregistry_test.go index fdd3575ff..030c971c1 100644 --- a/internal/praefect/protoregistry/protoregistry_test.go +++ b/internal/praefect/protoregistry/protoregistry_test.go @@ -156,7 +156,7 @@ func TestNewProtoRegistry(t *testing.T) { }, "SmartHTTPService": map[string]protoregistry.OpType{ "InfoRefsUploadPack": protoregistry.OpAccessor, - "InfoRefsReceivePack": protoregistry.OpMutator, + "InfoRefsReceivePack": protoregistry.OpAccessor, "PostUploadPack": protoregistry.OpAccessor, "PostReceivePack": protoregistry.OpMutator, }, diff --git a/proto/go/gitalypb/smarthttp.pb.go b/proto/go/gitalypb/smarthttp.pb.go index 67bd9faec..df9a6a04d 100644 --- a/proto/go/gitalypb/smarthttp.pb.go +++ b/proto/go/gitalypb/smarthttp.pb.go @@ -372,37 +372,37 @@ func init() { func init() { proto.RegisterFile("smarthttp.proto", fileDescriptor_7da929f3b109874f) } var fileDescriptor_7da929f3b109874f = []byte{ - // 477 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0x96, 0xd3, 0xae, 0xb0, 0xd7, 0x42, 0x2b, 0x4f, 0xb0, 0x28, 0x12, 0xac, 0x04, 0x09, 0xe5, - 0xd0, 0xb5, 0xd5, 0xb8, 0x70, 0x1e, 0x17, 0x76, 0xa2, 0x78, 0xdb, 0x05, 0x24, 0x22, 0x37, 0x71, - 0x3d, 0x0b, 0x37, 0x0e, 0xb1, 0x37, 0x69, 0x7f, 0x83, 0x0b, 0x1c, 0xf8, 0x1d, 0xfc, 0x04, 0x7e, - 0x12, 0x07, 0x4e, 0x28, 0x71, 0xbb, 0x2c, 0x4d, 0x83, 0x10, 0x88, 0x5b, 0xf2, 0xbe, 0xe7, 0xef, - 0x7d, 0xdf, 0xe7, 0x67, 0xe8, 0x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xcb, 0x31, 0x29, 0x36, 0x62, 0xc2, 0xd5, 0xea, 0x3f, 0x9d, 0xcf, 0x3b, 0x45, 0xe9, 0xf9, 0xaf, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x66, 0x0e, 0xc2, 0x08, 0xd8, 0x04, 0x00, 0x00, + // 475 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0xd5, 0x3a, 0x69, 0xa0, 0x93, 0x40, 0xa2, 0xa9, 0xa0, 0x96, 0x25, 0x68, 0x30, 0x12, 0xf2, + 0x21, 0x4d, 0xa2, 0x72, 0xe1, 0x5c, 0x2e, 0xf4, 0x44, 0x70, 0xdb, 0x0b, 0x48, 0x58, 0x1b, 0x7b, + 0xb3, 0x5d, 0xb1, 0xf1, 0x1a, 0xef, 0xb6, 0x52, 0x7f, 0x83, 0x0b, 0x1c, 0xf8, 0x0e, 0x3e, 0x81, + 0x4f, 0xe2, 0xc0, 0x09, 0xc5, 0x9b, 0xd4, 0x4d, 0x5c, 0x23, 0xa4, 0x88, 0xdb, 0xee, 0xbc, 0xd9, + 0x37, 0xf3, 0xde, 0xce, 0x40, 0x57, 0xcf, 0x69, 0x6e, 0x2e, 0x8c, 0xc9, 0x86, 0x59, 0xae, 0x8c, + 0xc2, 0x16, 0x17, 0x86, 0xca, 0x6b, 0x0f, 0xa4, 0x48, 0x8d, 0x8d, 0x79, 0x1d, 0x7d, 0x41, 0x73, + 0x96, 0xd8, 0x9b, 0xff, 0x9d, 0x40, 0xf7, 0x24, 0x9d, 0xa9, 0x90, 0xcd, 0x74, 0xc8, 0x3e, 0x5f, + 0x32, 0x6d, 0xf0, 0x15, 0x40, 0xce, 0x32, 0xa5, 0x85, 0x51, 0xf9, 0xb5, 0x4b, 0xfa, 0x24, 0x68, + 0x1f, 0xe1, 0xd0, 0x52, 0x0d, 0xc3,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c2, 0x7e, 0xc5, + 0x93, 0x7a, 0x0f, 0x8f, 0x7e, 0x39, 0xd0, 0x3b, 0x5d, 0xec, 0xc9, 0x9b, 0xb3, 0xb3, 0xc9, 0x29, + 0xcb, 0xaf, 0x44, 0xcc, 0xf0, 0x1d, 0xe0, 0x6a, 0xce, 0xca, 0xaf, 0xc0, 0xfd, 0x95, 0x7f, 0x1b, + 0x1b, 0xe2, 0xb9, 0x55, 0xc0, 0x56, 0xf4, 0x5b, 0xbf, 0xbf, 0x06, 0xce, 0x7d, 0x67, 0x4c, 0x30, + 0x84, 0xbd, 0x12, 0xbd, 0x69, 0x6d, 0x3b, 0xce, 0x0f, 0xf0, 0x70, 0x7d, 0x5a, 0xf0, 0xc9, 0xea, + 0xd5, 0x9d, 0xd3, 0xef, 0x3d, 0xad, 0x83, 0xd7, 0xa9, 0x03, 0x32, 0x26, 0xf8, 0x11, 0xba, 0x1b, + 0x3e, 0xe2, 0xda, 0xf3, 0xea, 0xd0, 0x79, 0x07, 0xb5, 0xf8, 0x1a, 0x3f, 0x59, 0xf0, 0x1f, 0x8f, + 0xdf, 0x2f, 0xb2, 0x25, 0x9d, 0x0e, 0x63, 0x35, 0x1f, 0xd9, 0xe3, 0xa1, 0xca, 0xf9, 0xc8, 0x72, + 0x8c, 0x8a, 0x89, 0x18, 0x71, 0xb5, 0xbc, 0x67, 0xd3, 0x69, 0xab, 0x08, 0xbd, 0xfc, 0x13, 0x00, + 0x00, 0xff, 0xff, 0xc2, 0x79, 0x15, 0x9d, 0xd8, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -422,8 +422,8 @@ type SmartHTTPServiceClient interface { // will upload the packs to that user. The user doesn't upload new objects. InfoRefsUploadPack(ctx context.Context, in *InfoRefsRequest, opts ...grpc.CallOption) (SmartHTTPService_InfoRefsUploadPackClient, error) // The response body for GET /info/refs?service=git-receive-pack - // Will be invoked when the user executes a `git push`, meaning the server - // will receive new objects in the pack from the user. + // Will be invoked when the user executes a `git push`, but only advertises + // references to the user. InfoRefsReceivePack(ctx context.Context, in *InfoRefsRequest, opts ...grpc.CallOption) (SmartHTTPService_InfoRefsReceivePackClient, error) // Request and response body for POST /upload-pack PostUploadPack(ctx context.Context, opts ...grpc.CallOption) (SmartHTTPService_PostUploadPackClient, error) @@ -572,8 +572,8 @@ type SmartHTTPServiceServer interface { // will upload the packs to that user. The user doesn't upload new objects. InfoRefsUploadPack(*InfoRefsRequest, SmartHTTPService_InfoRefsUploadPackServer) error // The response body for GET /info/refs?service=git-receive-pack - // Will be invoked when the user executes a `git push`, meaning the server - // will receive new objects in the pack from the user. + // Will be invoked when the user executes a `git push`, but only advertises + // references to the user. InfoRefsReceivePack(*InfoRefsRequest, SmartHTTPService_InfoRefsReceivePackServer) error // Request and response body for POST /upload-pack PostUploadPack(SmartHTTPService_PostUploadPackServer) error diff --git a/proto/smarthttp.proto b/proto/smarthttp.proto index 5a3e48eed..a9fe96c6d 100644 --- a/proto/smarthttp.proto +++ b/proto/smarthttp.proto @@ -18,11 +18,11 @@ service SmartHTTPService { } // The response body for GET /info/refs?service=git-receive-pack - // Will be invoked when the user executes a `git push`, meaning the server - // will receive new objects in the pack from the user. + // Will be invoked when the user executes a `git push`, but only advertises + // references to the user. rpc InfoRefsReceivePack(InfoRefsRequest) returns (stream InfoRefsResponse) { option (op_type) = { - op: MUTATOR + op: ACCESSOR }; } diff --git a/ruby/proto/gitaly/smarthttp_services_pb.rb b/ruby/proto/gitaly/smarthttp_services_pb.rb index 39c3aebc9..11a6e87b1 100644 --- a/ruby/proto/gitaly/smarthttp_services_pb.rb +++ b/ruby/proto/gitaly/smarthttp_services_pb.rb @@ -19,8 +19,8 @@ module Gitaly # will upload the packs to that user. The user doesn't upload new objects. rpc :InfoRefsUploadPack, Gitaly::InfoRefsRequest, stream(Gitaly::InfoRefsResponse) # The response body for GET /info/refs?service=git-receive-pack - # Will be invoked when the user executes a `git push`, meaning the server - # will receive new objects in the pack from the user. + # Will be invoked when the user executes a `git push`, but only advertises + # references to the user. rpc :InfoRefsReceivePack, Gitaly::InfoRefsRequest, stream(Gitaly::InfoRefsResponse) # Request and response body for POST /upload-pack rpc :PostUploadPack, stream(Gitaly::PostUploadPackRequest), stream(Gitaly::PostUploadPackResponse) |