client-go icon indicating copy to clipboard operation
client-go copied to clipboard

Replace unistore with mockstore for `testAsyncCommitFailSuite`

Open disksing opened this issue 3 years ago • 3 comments

Replace

https://github.com/tikv/client-go/blob/8c3f29a55f1015e6d4d5cf2e121999ddb224833f/integration_tests/async_commit_test.go#L80-L83

with

client, cluster, pdClient, err := testutils.NewMockTiKV("", nil)
s.Require().Nil(err) 
testutils.BootstrapWithSingleStore(cluster)

Then make sure tests can pass.

disksing avatar Mar 04 '22 06:03 disksing

I have been working on it over here, currently having issues passing some integration tests.

ericcz0 avatar Jul 19 '22 00:07 ericcz0

I'm currently having issues with TestRepeatableRead. AFAICT, the test is not actually failing due to write skew, but due to some kind of issue with the mock server returning minimum commit timestamps that are too late, causing commits to be pushed back each time.

=== RUN   TestAsyncCommit/TestRepeatableRead
[2022/07/18 18:55:40.449 -07:00] [INFO] [commit.go:149] ["2PC commitTS rejected by TiKV, retry with a newer commitTS"] [txnStartTS=434686064184262656] [info="{StartTs:434686064184262656 AttemptedCommitTs:434686064184262658 Key:6b31 MinCommitTs:434686064184262660}"]
    async_commit_test.go:134: 
        	Error Trace:	async_commit_test.go:134
        	            				async_commit_test.go:413
        	            				async_commit_test.go:438
        	Error:      	Expected nil, but got: not exist
        	Test:       	TestAsyncCommit/TestRepeatableRead
    async_commit_test.go:135: 
        	Error Trace:	async_commit_test.go:135
        	            				async_commit_test.go:413
        	            				async_commit_test.go:438
        	Error:      	Not equal: 
        	            	expected: []byte(nil)
        	            	actual  : []byte{0x76, 0x31}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,2 +1,4 @@
        	            	-([]uint8) <nil>
        	            	+([]uint8) (len=2) {
        	            	+ 00000000  76 31                                             |v1|
        	            	+}
        	            	 
        	Test:       	TestAsyncCommit/TestRepeatableRead
[2022/07/18 18:55:40.450 -07:00] [WARN] [2pc.go:1808] ["schemaLeaseChecker is not set for this transaction"] [sessionID=1] [startTS=434686064184262659] [checkTS=434686064184262659]
    async_commit_test.go:425: 
        	Error Trace:	async_commit_test.go:425
        	            				async_commit_test.go:438
        	Error:      	Expected nil, but got: write conflict { start_ts:434686064184262659 conflict_ts:434686064184262656 key:"k1" conflict_commit_ts:434686064184524800  }
        	Test:       	TestAsyncCommit/TestRepeatableRead
    async_commit_test.go:135: 
        	Error Trace:	async_commit_test.go:135
        	            				async_commit_test.go:433
        	            				async_commit_test.go:438
        	Error:      	Not equal: 
        	            	expected: []byte{0x76, 0x31}
        	            	actual  : []byte{0x76, 0x32}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,3 +1,3 @@
        	            	 ([]uint8) (len=2) {
        	            	- 00000000  76 31                                             |v1|
        	            	+ 00000000  76 32                                             |v2|
        	            	 }
        	Test:       	TestAsyncCommit/TestRepeatableRead
[2022/07/18 18:55:40.451 -07:00] [INFO] [commit.go:149] ["2PC commitTS rejected by TiKV, retry with a newer commitTS"] [txnStartTS=434686064184786946] [info="{StartTs:434686064184786946 AttemptedCommitTs:434686064184786948 Key:6b31 MinCommitTs:434686064184786950}"]
[2022/07/18 18:55:40.451 -07:00] [WARN] [2pc.go:1808] ["schemaLeaseChecker is not set for this transaction"] [sessionID=2] [startTS=434686064184786949] [checkTS=434686064184786949]
    async_commit_test.go:425: 
        	Error Trace:	async_commit_test.go:425
        	            				async_commit_test.go:439
        	Error:      	Expected nil, but got: write conflict { start_ts:434686064184786949 conflict_ts:434686064184786946 key:"k1" conflict_commit_ts:434686064184786971  }
        	Test:       	TestAsyncCommit/TestRepeatableRead
    async_commit_test.go:135: 
        	Error Trace:	async_commit_test.go:135
        	            				async_commit_test.go:433
        	            				async_commit_test.go:439
        	Error:      	Not equal: 
        	            	expected: []byte{0x76, 0x31}
        	            	actual  : []byte{0x76, 0x32}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,3 +1,3 @@
        	            	 ([]uint8) (len=2) {
        	            	- 00000000  76 31                                             |v1|
        	            	+ 00000000  76 32                                             |v2|
        	            	 }
        	Test:       	TestAsyncCommit/TestRepeatableRead

Here, the changes made by the initial putKV statement are not committed due to the commit being too early, and the commit is pushed back. Meanwhile, the test reaches line 433, where the program expects to read a version of the data that has already committed these changes.

ericcz0 avatar Jul 19 '22 01:07 ericcz0

You are right. I think the reason could be that mock server does not implement all advanced features that tikv supports.

disksing avatar Jul 25 '22 04:07 disksing