Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace unistore with mockstore for testAsyncCommitFailSuite #441

Open
Tracked by #440
disksing opened this issue Mar 4, 2022 · 3 comments
Open
Tracked by #440

Replace unistore with mockstore for testAsyncCommitFailSuite #441

disksing opened this issue Mar 4, 2022 · 3 comments

Comments

@disksing
Copy link
Collaborator

disksing commented Mar 4, 2022

Replace

client, pdClient, cluster, err := unistore.New("")
s.Require().Nil(err)
unistore.BootstrapWithSingleStore(cluster)

with

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

Then make sure tests can pass.

@ericcz0
Copy link

ericcz0 commented Jul 19, 2022

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

@ericcz0
Copy link

ericcz0 commented Jul 19, 2022

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.

@disksing
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants