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

rfc: Resolved-ts for Large Transactions #114

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

ekexium
Copy link
Contributor

@ekexium ekexium commented Aug 15, 2024

No description provided.

@ekexium ekexium force-pushed the resolved-ts-large-txn branch from bc2bfc0 to 6d84526 Compare August 15, 2024 15:11
@ekexium ekexium force-pushed the resolved-ts-large-txn branch from 6d84526 to 93f799e Compare August 15, 2024 15:21
Signed-off-by: ekexium <[email protected]>
@ekexium ekexium force-pushed the resolved-ts-large-txn branch from 7938582 to 4fa64e3 Compare August 23, 2024 01:47
Signed-off-by: ekexium <[email protected]>
@ekexium ekexium force-pushed the resolved-ts-large-txn branch from 6b03fb1 to 813b856 Compare August 28, 2024 01:53
@ekexium ekexium marked this pull request as ready for review August 28, 2024 01:54
@ekexium ekexium requested a review from overvenus August 30, 2024 06:19

*TBD: should it also update max_ts?*

#### TiKV txn_status_cache
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it mean that it requires all information about these large txns must exist in the cache? If so, I'm afraid it's no longer a cache as literal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The cache operates on a "best effort" basis rather than being mandatory. In the case of cache miss, the system falls back to use start_ts.

#### 3.2.1 Coordinator

**Proposed Change:**
- TTL manager fetches latest TSO as min_commit_ts candidate.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the TTL manager the worker in tidb which updates the TTL of primary key for each transaction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because we want to piggyback the min_commit_ts in the heartbeat message.


## 5. Cost Analysis

- Memory: ~33 bytes per cache entry. TiKV instances can hold millions of entries.
Copy link
Contributor

Choose a reason for hiding this comment

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

IS it 33 bytes for each transaction? Why 33 bytes total?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. The minimum memory requirement for each cache entry is 33:
8 (start_ts) + 8 (min_commit_ts) + 1 (status) + 8 (TTL) = 33 bytes.
I've clarified this in the doc.

- The TTL manager goroutine fetches latest TSO as min_commit_ts candidate.
- Updates committer's inner state and PK in TiKV.
- PK update piggybacked on `heartbeat` request.
- Broadcasts `start_ts` and new `min_commit_ts` to all TiKV stores.
Copy link
Contributor

Choose a reason for hiding this comment

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

Will there be kvproto changes like adding new KV interfaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 describe it in the document.

Signed-off-by: ekexium <[email protected]>
Copy link
Contributor

@cfzjywxk cfzjywxk left a comment

Choose a reason for hiding this comment

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

LGTM

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

Successfully merging this pull request may close these issues.

3 participants