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

store/tikv: refactor the ResolveLocks() function for large transaction's implementation #11999

Merged
merged 22 commits into from Oct 14, 2019

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Sep 3, 2019

What problem does this PR solve?

After introducing the large transaction, the true lock TTL information is stored in the primary lock, and the TTL may change.
This commit updates the resolve lock method, using the new kvproto API.

What is changed and how it works?

Tiny refactor to adapt the new kvproto API.
Blocked by #11974 which implements the CheckTxnStatus API, please review that one first.

Check List

Tests

  • No code

…n's implementation

After introducing the large transaction, the true lock TTL information is stored
in the primary lock, and the TTL may change.
This commit updates the resolve lock method, using the new kvproto API
@codecov
Copy link

codecov bot commented Sep 11, 2019

Codecov Report

Merging #11999 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #11999   +/-   ##
===========================================
  Coverage   79.9206%   79.9206%           
===========================================
  Files           461        461           
  Lines        104087     104087           
===========================================
  Hits          83187      83187           
  Misses        14795      14795           
  Partials       6105       6105

@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @lysu @MyonKeminta

@coocood
Copy link
Member

coocood commented Sep 12, 2019

It's actually blocked by tikv/tikv#5390 for integration test.

@MyonKeminta
Copy link
Contributor

tikv/tikv#5390 is ready for reviewing, though I'll add some more test to it

store/tikv/2pc.go Outdated Show resolved Hide resolved
@tiancaiamao
Copy link
Contributor Author

tiancaiamao commented Sep 23, 2019

I'll update this PR after merging #12212

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@tiancaiamao
Copy link
Contributor Author

/run-integration-common-test tikv=pr/5390

@tiancaiamao
Copy link
Contributor Author

/run-all-tests tikv=pr/5390

@tiancaiamao
Copy link
Contributor Author

PTAL @MyonKeminta @youjiali1995 @coocood

store/tikv/lock_resolver.go Outdated Show resolved Hide resolved
@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @MyonKeminta

@tiancaiamao
Copy link
Contributor Author

I find there so many repeated codes like this

	for {
		loc, err := lr.store.GetRegionCache().LocateKey(bo, primary)
		if err != nil {
			return status, errors.Trace(err)
		}
		resp, err := lr.store.SendReq(bo, req, loc.Region, readTimeoutShort)
		if err != nil {
			return status, errors.Trace(err)
		}
		regionErr, err := resp.GetRegionError()
		if err != nil {
			return status, errors.Trace(err)
		}

and I will clean up them after this PR

@tiancaiamao
Copy link
Contributor Author

  • getTxnStatusFromLock now cleanup primary lock correctly
  • The test is updated to cover secondary lock and lock.TTL = 0

@MyonKeminta @coocood @sticnarf @youjiali1995

@youjiali1995
Copy link
Contributor

LGTM

Copy link
Contributor

@sticnarf sticnarf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest LGTM

@MyonKeminta
Copy link
Contributor

/run-all-tests tikv=pr/5390

@coocood coocood added the status/can-merge Indicates a PR has been approved by a committer. label Oct 14, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Oct 14, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Oct 14, 2019

@tiancaiamao merge failed.

@tiancaiamao
Copy link
Contributor Author

/run-integration-common-test

@tiancaiamao
Copy link
Contributor Author

/run-unit-test

1 similar comment
@zyxbest
Copy link
Contributor

zyxbest commented Oct 14, 2019

/run-unit-test

@tiancaiamao
Copy link
Contributor Author

That's weird.

[2019-10-14T05:40:07.994Z] ----------------------------------------------------------------------
[2019-10-14T05:40:07.994Z] FAIL: github.com/pingcap/tidb@/config/config_test.go:37: testConfigSuite.TestConfig
[2019-10-14T05:40:07.994Z] 
[2019-10-14T05:40:07.994Z] github.com/pingcap/tidb@/config/config_test.go:50:
[2019-10-14T05:40:07.994Z]     ...open github.com/pingcap/tidb@/config/config_test.go: no such file or directory
[2019-10-14T05:40:07.994Z] ... value *os.PathError = &os.PathError{Op:"open", Path:"github.com/pingcap/tidb@/config/config.toml", Err:0x2} ("open github.com/pingcap/tidb@/config/config.toml: no such file or directory")
[2019-10-14T05:40:07.994Z] 
[2019-10-14T05:40:07.994Z] 
[2019-10-14T05:40:07.994Z] ----------------------------------------------------------------------

@tiancaiamao tiancaiamao merged commit eda7656 into pingcap:master Oct 14, 2019
@tiancaiamao tiancaiamao deleted the resolve-lock branch October 14, 2019 05:54

if status.ttl > 0 {
// Do not clean lock that is not expired.
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function need to resolve all locks in locks. If some of the locks can't be resolved, this function shouldn't return true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then large txn would block GC...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To continue GC anyway, you should resolve all the locks before cleaning up the data. Otherwise not-committed secondaries may miss their primary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may remove these locks regardless of their TTL (of course, primary first), but you can never leave these locks there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to update the CmdGCRequest instead of simply leave the lock here.
@coocood

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will GC's logic be? By the way, GC Request is not used by default now.

XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
…n's implementation (pingcap#11999)

After introducing the large transaction, the true lock TTL information is stored
in the primary lock, and the TTL may change.
This commit updates the resolve lock method, using the new kvproto CheckTxnStatus API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tikv sig/transaction SIG:Transaction status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants