You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #19817 , we are going to support timestamp bounded read-only transactions. There are 2 kinds of query for the timestamp bounded read-only transactions
exact staleness
-- start a read-only transaction which reads the exact snapshot 5 seconds ago:START TRANSACTION READ ONLY WITH TIMESTAMP BOUND EXACT STALENESS '00:00:05';
-- start a read-only transaction which reads the exact snapshot at "2020-09-06 00:00:00":START TRANSACTION READ ONLY WITH TIMESTAMP BOUND READ TIMESTAMP'2020-09-06 00:00:00';
For the first query, we need to generate a TSO which represents for the TSO 5 secs ago. For the second query, we need to generate a TSO which represents the timestamp 2020-09-06 00:00:00. After the TSO generated, the tidb-server will send the request by holding the stale TSO to read the stale data.
time-bounded staleness
-- start a read-only transaction which reads the data no stale than 10 seconds ago:START TRANSACTION READ ONLY WITH TIMESTAMP BOUND MAX STALENESS '00:00:10'-- start a read-only transaction which reads the data no stale than '2019-11-04 00:00:00':START TRANSACTION READ ONLY WITH TIMESTAMP BOUND MIN READ TIMESTAMP'2019-11-04 00:00:00';
For the first query, we need to generate a TSO which represents for the TSO 10 secs ago. For the second query, we need to generate a TSO which represents the timestamp 2019-11-04 00:00:00. After the TSO generated, the tidb-server will send the request hold holding the TSO range [stale TSO, latest TSO] to read the time-bounded data.
Implementation
The tidb-server use Oracle interface to request TSO from PD. The TSO including 2 part, the physical part and the logical part. The accuracy of the physical part is ms.
For the stale TSO like 10 sec ago, we will provide a function in Oraclie like GetStaleTimestamp(prev int) and prev indicates for the seconds. To achieve this target, we will split this task in 2 sides.
PD
In PD, we need to mantain the last GlobalTSO and its arrival timestamp in pdClient. The pdClient should provide a function like GetLastGlobalTSO()(currentyly we only support global)
TiDB
In TiDB, GetStaleTimestamp(prev int) will directly call the GetLastGlobalTSO() and calculate the stale TSO. For example, the 10 secs ago stale TSO would be generated like following:
last global TSO - (tidb_clock_time(lastTS arrived) - tidb_clock_time(10s ago))
As each tidb-server will call Global TSO each 2 seconds, the difference inaccuracy error will be limited into 2 sec which is accptable.
The text was updated successfully, but these errors were encountered:
Development Task
In #19817 , we are going to support timestamp bounded read-only transactions. There are 2 kinds of query for the
timestamp bounded read-only transactions
For the first query, we need to generate a TSO which represents for the TSO 5 secs ago. For the second query, we need to generate a TSO which represents the timestamp
2020-09-06 00:00:00
. After the TSO generated, the tidb-server will send the request by holding the stale TSO to read the stale data.For the first query, we need to generate a TSO which represents for the TSO 10 secs ago. For the second query, we need to generate a TSO which represents the timestamp
2019-11-04 00:00:00
. After the TSO generated, the tidb-server will send the request hold holding the TSO range [stale TSO, latest TSO] to read the time-bounded data.Implementation
The
tidb-server
useOracle
interface to requestTSO
from PD. TheTSO
including 2 part, thephysical
part and thelogical
part. The accuracy of the physical part isms
.For the stale TSO like
10 sec ago
, we will provide a function in Oraclie likeGetStaleTimestamp(prev int)
andprev
indicates for the seconds. To achieve this target, we will split this task in 2 sides.PD
In PD, we need to mantain the last GlobalTSO and its
arrival timestamp
inpdClient
. The pdClient should provide a function likeGetLastGlobalTSO()
(currentyly we only supportglobal
)TiDB
In TiDB,
GetStaleTimestamp(prev int)
will directly call theGetLastGlobalTSO()
and calculate thestale TSO
. For example, the10 secs ago
stale TSO would be generated like following:As each tidb-server will call
Global TSO
each 2 seconds, the difference inaccuracy error will be limited into2 sec
which is accptable.The text was updated successfully, but these errors were encountered: