-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
56667: sql: normalize age and timestamptz intervals like postgres r=solongordon a=otan sql: normalize age and timestamptz intervals like postgres Release note (sql change, bug fix): Previously, `timestamp/timestamptz - timestamp/timestamptz` operators would normalize the interval into months, days, H:M:S (in older versions, this may be just H:M:S). This could result in an incorrect result: ``` > select '2020-01-01'::timestamptz - '2018-01-01'; ?column? ------------------- 2 years 10 days ``` This has now been fixed such that it is only normalized into days/H:M:S. This is now more postgres compatible. Release note (sql change, bug fix): Previously, the `age` builtin would incorrectly normalize months and days based on 30 days a month (in older versions this may be just H:M:S). This can give an incorrect result, e.g. ``` > select age('2020-01-01'::timestamptz, '2018-01-01'); ?column? ------------------- 2 years 10 days ``` This is not the most accurate it could be as `age` can use the given timestamptz arguments to be more accurate. This is now more postgres compatible. Revert "sql: age returns normalized intervals" This reverts commit 88a5d94. Release note: None 56679: kv: use leaseholder's observed timestamp even for follower reads r=nvanbenschoten a=nvanbenschoten This commit addresses a longstanding TODO to rationalize the use of observed timestamps during follower reads. Before this change, we used to use observed timestamps pulled from the follower node to limit a transaction's uncertainty interval, but this was incorrect. An observed timestamp pulled from the follower node's clock has no meaning for the purpose of reducing the transaction's uncertainty interval. This is because there is no guarantee that at the time of acquiring the observed timestamp from the follower node, the leaseholder hadn't already served writes at higher timestamps than the follower node's clock reflected. However, if the transaction performing a follower read happens to have an observed timestamp from the current leaseholder, this timestamp can be used to reduce the transaction's uncertainty interval. Even though the read is being served from a different replica in the range, the observed timestamp still places a bound on the values in the range that may have been written before the transaction began. In the past, this was mostly innocuous because AOST txns don't have an uncertainty interval and the follower read duration was so large that very few "present time" transactions would ever perform follower reads. Now that the follower read duration is lower and more and more present time transactions will perform follower reads, this is more critical to get right. The change also reworks the observedts package's docs a little bit to take advantage of section headers: ![localhost_8080_pkg_github com_cockroachdb_cockroach_pkg_kv_kvserver_observedts_](https://user-images.githubusercontent.com/5438456/99130331-0d3cfc00-25de-11eb-9f49-616bfed9fc55.png) Co-authored-by: Oliver Tan <[email protected]> Co-authored-by: Nathan VanBenschoten <[email protected]>
- Loading branch information
Showing
15 changed files
with
431 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.