Skip to content

feat: Broadcast min_commit_ts for pipelined transactions#1458

Merged
ti-chi-bot[bot] merged 24 commits intotikv:masterfrom
ekexium:feat-resolved-ts-for-large-txn
Sep 25, 2024
Merged

feat: Broadcast min_commit_ts for pipelined transactions#1458
ti-chi-bot[bot] merged 24 commits intotikv:masterfrom
ekexium:feat-resolved-ts-for-large-txn

Conversation

@ekexium
Copy link
Contributor

@ekexium ekexium commented Sep 5, 2024

Ref: tikv/tikv#17459
Prerequires pingcap/kvproto#1265

Changes

  1. Periodic updates of min_commit_ts
  2. Broadcast min_commit_ts
  3. Periodic updates of full store list

Signed-off-by: ekexium <eke@fastmail.com>
Signed-off-by: ekexium <eke@fastmail.com>
@ti-chi-bot ti-chi-bot bot added dco-signoff: yes Indicates the PR's author has signed the dco. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 5, 2024
Signed-off-by: ekexium <eke@fastmail.com>
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 5, 2024
Signed-off-by: ekexium <eke@fastmail.com>
Signed-off-by: ekexium <eke@fastmail.com>
Signed-off-by: ekexium <eke@fastmail.com>
Signed-off-by: ekexium <eke@fastmail.com>
Signed-off-by: ekexium <eke@fastmail.com>
@ekexium ekexium force-pushed the feat-resolved-ts-for-large-txn branch from 1789ae4 to ad0302e Compare September 19, 2024 07:36
Copy link
Contributor

@you06 you06 left a comment

Choose a reason for hiding this comment

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

BTW, this is not related to this PR, can you change the RLock/RUnlock to Lock/Unlock here?

I have a question about the future plan, have you considered apply this broadcast also for slow or large 2pc transactions?

ekexium and others added 4 commits September 19, 2024 19:55
Co-authored-by: you06 <you1474600@gmail.com>
Signed-off-by: ekexium <eke@fastmail.com>
Signed-off-by: ekexium <eke@fastmail.com>
Signed-off-by: ekexium <eke@fastmail.com>
@ekexium
Copy link
Contributor Author

ekexium commented Sep 20, 2024

BTW, this is not related to this PR, can you change the RLock/RUnlock to Lock/Unlock here?

Done.

I have a question about the future plan, have you considered apply this broadcast also for slow or large 2pc transactions?

It's possible. But I think we need more empirical data before implementing that. It's unclear now how this optimization would benefit normal large transactions.

Co-authored-by: crazycs <crazycs520@gmail.com>
ekexium and others added 4 commits September 23, 2024 17:23
Signed-off-by: ekexium <eke@fastmail.com>
Co-authored-by: crazycs <crazycs520@gmail.com>
Signed-off-by: ekexium <eke@fastmail.com>
…lient-go into feat-resolved-ts-for-large-txn
Comment on lines +751 to +757
if store == nil || store.GetState() == metapb.StoreState_Tombstone {
s.setResolveState(tombstone)
continue
}
addr := store.GetAddress()
if addr == "" {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to explain in the comments when the pdClient.GetAllStores(ctx) may return a store list containg nil store and emptry address and how should they be treated. For example, dose it mean the returned store list is invalid and pdClient.GetAllStores(ctx) should be retried when there invalid element in the list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe that GetAllStores is supposed to return only stores in Up and Offline states. This additional check serves as a defensive measure and ensures consistency with the store resolve procedure

Signed-off-by: ekexium <eke@fastmail.com>
wg.Wait()
}

if err := txn.spawnWithStorePool(broadcastFunc); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we've already used a goroutine pool, how about spawning broadcast tasks like the following:

	stores := store.GetRegionCache().GetStoresByType(tikvrpc.TiKV)
	rateLimit := make(chan struct{}, min(broadcastMaxConcurrency, len(stores)))
	for _, s := range stores {
		rateLimit <- struct{}{}
		target := s
		err := txn.spawnWithStorePool(func() {
			defer func() {
				<-rateLimit
			}()
			// send request to target
		})
		if err != nil {
			<-rateLimit
		}
	}

Signed-off-by: ekexium <eke@fastmail.com>
Signed-off-by: ekexium <eke@fastmail.com>
@ekexium ekexium force-pushed the feat-resolved-ts-for-large-txn branch from afbcb64 to 4aada7a Compare September 24, 2024 08:33
@ekexium ekexium force-pushed the feat-resolved-ts-for-large-txn branch from 3e9a4ec to 012425a Compare September 24, 2024 08:45
Signed-off-by: ekexium <eke@fastmail.com>
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Sep 24, 2024
@ti-chi-bot ti-chi-bot bot added the lgtm label Sep 25, 2024
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, zyguan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 25, 2024
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 25, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-24 12:53:30.169772239 +0000 UTC m=+1570479.910196175: ☑️ agreed by zyguan.
  • 2024-09-25 01:31:10.938538581 +0000 UTC m=+1615940.678962520: ☑️ agreed by cfzjywxk.

@ti-chi-bot ti-chi-bot bot merged commit 527f80a into tikv:master Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants