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

[YSQL] Provide a spanner-like behavior to wait out the clock skew at commit time. #22317

Open
1 task done
pao214 opened this issue May 8, 2024 · 0 comments
Open
1 task done
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue

Comments

@pao214
Copy link
Contributor

pao214 commented May 8, 2024

Jira Link: DB-11226

Description

Context

We use hybrid timestamping mechanism to decide ordering between commits and reads. But this is problematic since clocks are skewed in a distributed database such as YB. This skew can be mitigated in two ways,

  1. Use a spanner-like solution where you wait out the skew at commit time.
  2. Use an uncertainty window during the read time to detect any commits that may have happened before us (but have a timestamp higher than that of the read).

YB uses approach 2, since approach 1 is too expensive when clock skews are high. The clock skews have gotten as large as 500ms in the past.

Motivation

However, times have changed, and clouds now provide services to get highly accurate clocks. For example, AWS provides announced microsecond-accurate clocks in their recent changes to AWS Time Sync Service.

In the presence of such accurate clocks, we wish to employ a spanner-like approach (approach 1). This has a couple of advantages

  1. The waiting can be done in parallel to raft replication of the commit status. When clock skews are small, the raft replication takes longer, and we do not spend any additional time waiting.
  2. We get external consistency for free.
  3. No read restart errors at all.

Objective

  1. Minimize clock skew

Explore AWS Time Sync Service. Use AWS Nitro system, configure PTP hardware clocks and use tight update intervals to see how good we can bound the clock skew. This AWS blog mentions that the clock error is typically bounded by 40us. Even with NTP (not PTP), we should get a 100us time. This is very much acceptable.

  1. Check for inefficiencies in how we measure clock error bound.

I have also noticed that ntp_adjtime gives an error that is couple orders of magnitude higher than what chrony gives us. Use aws clock bound implementation as a reference.

  1. Provide an option to wait out the clock skew at commit time.

This cannot be a runtime flag because of changes in hyrbid time values. Ideally, this is an AUTO FLAG.

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@pao214 pao214 added area/ysql Yugabyte SQL (YSQL) status/awaiting-triage Issue awaiting triage labels May 8, 2024
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels May 8, 2024
@pao214 pao214 self-assigned this Jun 19, 2024
@pao214 pao214 added kind/enhancement This is an enhancement of an existing feature and removed kind/bug This issue is a bug labels Jun 29, 2024
@yugabyte-ci yugabyte-ci removed the status/awaiting-triage Issue awaiting triage label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue
Projects
Status: No status
Development

No branches or pull requests

2 participants