nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: tikv/client-go
Pull request #960 (2023-09-07 08:30:29)

request_source: set the request source at the last section
As https://github.com/tikv/client-go/pull/953#issuecomment-1708749115 says, the format modified by #953 is not compatible with TiKV, this PR set the request source as the last section, so that TiKV can handle it correctly.


Patch:
diff --git a/internal/locate/region_request.go b/internal/locate/region_request.go
index 6324287..6a89942 100644
--- a/internal/locate/region_request.go
+++ b/internal/locate/region_request.go
@@ -2337,9 +2337,10 @@ func (s *replicaSelector) replicaType(rpcCtx *RPCContext) string {
 
 func (s *replicaSelector) patchRequestSource(req *tikvrpc.Request, rpcCtx *RPCContext) {
 	var sb strings.Builder
-	sb.WriteString(req.InputRequestSource)
-	sb.WriteByte('-')
 	defer func() {
+		// TiKV does the limit control by the last part of the request source.
+		sb.WriteByte('_')
+		sb.WriteString(req.InputRequestSource)
 		req.RequestSource = sb.String()
 	}()
 


Test patch:
diff --git a/internal/locate/region_request3_test.go b/internal/locate/region_request3_test.go
index 7a92c58..6d14fef 100644
--- a/internal/locate/region_request3_test.go
+++ b/internal/locate/region_request3_test.go
@@ -1515,7 +1515,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestRetryRequestSource() {
 			rpcCtx, err := replicaSelector.buildRPCContext(bo)
 			s.Nil(err)
 			replicaSelector.patchRequestSource(req, rpcCtx)
-			s.Equal("test-"+firstReplica, req.RequestSource)
+			s.Equal(firstReplica+"_test", req.RequestSource)
 
 			// retry
 			setReadType(req, retryReplica)
@@ -1526,7 +1526,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestRetryRequestSource() {
 			s.Nil(err)
 			req.IsRetryRequest = true
 			replicaSelector.patchRequestSource(req, rpcCtx)
-			s.Equal("test-retry_"+firstReplica+"_"+retryReplica, req.RequestSource)
+			s.Equal("retry_"+firstReplica+"_"+retryReplica+"_test", req.RequestSource)
 		}
 	}
 }
Repository: tikv/client-go
Pull request #1052 (2023-11-08 07:42:59)

make `ContainsByEnd` return `true` when the key is empty and region's right bound is inf
Signed-off-by: hillium <yujuncen@pingcap.com>

Ref: https://github.com/tikv/client-go/issues/1051

I think the semantic of `ContainsByEnd` should be: "Please check whether this key is in the range, if the input is empty, treat it as infinity.". But I have noticed there are already some test cases that believes "" shouldn't be in ("", ""]. I'm not sure whether it is by design.

Anyway this will bring unexpected behavior sometimes (say, make infinity loops), I think perhaps we can make it better.


YuJuncen: /cc @disksing 
disksing: I think you're right, but I need to check all usages of this function to prevent this modification from accidentally breaking something.
disksing: > I think you're right, but I need to check all usages of this function to prevent this modification from accidentally breaking something.

checked, it should be fine.

Patch:
diff --git a/internal/locate/region_cache.go b/internal/locate/region_cache.go
index f548f13..7305fe8 100644
--- a/internal/locate/region_cache.go
+++ b/internal/locate/region_cache.go
@@ -2468,6 +2468,10 @@ func (r *Region) Contains(key []byte) bool {
 // for the maximum region endKey is empty.
 // startKey < key <= endKey.
 func (r *Region) ContainsByEnd(key []byte) bool {
+	// Only a region's right bound expands to inf contains the point at inf.
+	if len(key) == 0 {
+		return len(r.EndKey()) == 0
+	}
 	return bytes.Compare(r.meta.GetStartKey(), key) < 0 &&
 		(bytes.Compare(key, r.meta.GetEndKey()) <= 0 || len(r.meta.GetEndKey()) == 0)
 }


Test patch:
diff --git a/internal/locate/region_cache_test.go b/internal/locate/region_cache_test.go
index 5471809..f583dc7 100644
--- a/internal/locate/region_cache_test.go
+++ b/internal/locate/region_cache_test.go
@@ -1374,9 +1374,9 @@ func (s *testRegionCacheSuite) TestContains() {
 }
 
 func (s *testRegionCacheSuite) TestContainsByEnd() {
-	s.False(createSampleRegion(nil, nil).ContainsByEnd([]byte{}))
+	s.True(createSampleRegion(nil, nil).ContainsByEnd([]byte{}))
 	s.True(createSampleRegion(nil, nil).ContainsByEnd([]byte{10}))
-	s.False(createSampleRegion([]byte{10}, nil).ContainsByEnd([]byte{}))
+	s.True(createSampleRegion([]byte{10}, nil).ContainsByEnd([]byte{}))
 	s.False(createSampleRegion([]byte{10}, nil).ContainsByEnd([]byte{10}))
 	s.True(createSampleRegion([]byte{10}, nil).ContainsByEnd([]byte{11}))
 	s.False(createSampleRegion(nil, []byte{10}).ContainsByEnd([]byte{}))
Repository: argoproj/argo
Pull request #3311 (2020-06-25 20:42:54)

build: Pin `goimports` to working version
Checklist:

* [x] Either (a) I've created an [enhancement proposal](https://github.com/argoproj/argo/issues/new/choose) and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
* [x] The title of the PR is (a) [conventional](https://www.conventionalcommits.org/en/v1.0.0/), (b) states what changed, and (c) suffixes the related issues number. E.g. `"fix(controller): Updates such and such. Fixes #1234"`.  
* [x] I've signed the CLA.
* [ ] I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
* [x] My builds are green. Try syncing with master if they are not. 
* [x] My organization is added to [USERS.md](https://github.com/argoproj/argo/blob/master/USERS.md).


alexec: @simster7 can you please review and merge when you're happy?

Patch:
diff --git a/hack/generate-proto.sh b/hack/generate-proto.sh
index f30119753..92f842f7b 100755
--- a/hack/generate-proto.sh
+++ b/hack/generate-proto.sh
@@ -6,7 +6,7 @@ go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.12.2
 go get github.com/gogo/protobuf/protoc-gen-gogo@v1.3.1
 go get github.com/gogo/protobuf/protoc-gen-gogofast@v1.3.1
 go get github.com/gogo/protobuf/gogoproto@v1.3.1
-go get golang.org/x/tools/cmd/goimports
+go get golang.org/x/tools/cmd/goimports@v0.0.0-20200428211428-0c9eba77bc32
 go install k8s.io/code-generator/cmd/go-to-protobuf
 go-to-protobuf \
     --go-header-file=./hack/custom-boilerplate.go.txt \
diff --git a/util/grpc/errors.go b/util/grpc/errors.go
index bfb3ebd2a..fe56b849f 100644
--- a/util/grpc/errors.go
+++ b/util/grpc/errors.go
@@ -31,4 +31,4 @@ func TranslateError(err error) error {
 		return status.Error(codes.Internal, err.Error())
 	}
 	return err
-}
\ No newline at end of file
+}


Test patch:
diff --git a/config/node_events_test.go b/config/node_events_test.go
index 394e343a2..b9f70ef40 100644
--- a/config/node_events_test.go
+++ b/config/node_events_test.go
@@ -11,4 +11,4 @@ func TestNodeEvents_IsEnabled(t *testing.T) {
 	assert.True(t, NodeEvents{}.IsEnabled())
 	assert.False(t, NodeEvents{Enabled: pointer.BoolPtr(false)}.IsEnabled())
 	assert.True(t, NodeEvents{Enabled: pointer.BoolPtr(true)}.IsEnabled())
-}
\ No newline at end of file
+}