From: Michael P. <mic...@gm...> - 2010-12-02 04:40:29
|
Sorry for my late reply. On Wed, Dec 1, 2010 at 7:34 AM, Mason Sharp <mas...@en...>wrote: > > >> For statement_timestamp() do we perform a separate operation through >> GTM, or do we do a delta similar to clock_timestamp()? >> > statement_timestamo and transaction timestamp base their calculations based > on delta calculated with GTM. > clock_timestamp does not do anything with GTM, it just uses the local node > timestamp. > > Transaction_timestamp should just use the value piggybacked from GTM with > XID and not a delta though. The same value should be used on all nodes > involved in the transaction, right? > When a transaction is begun on a node, the transaction timestamp is sent along with snapshot and gxid. The value sent is of course the one calculated at Coordinator. You are right that we should send directly the timestamp value got at GTM... But if you have a look at the code, in xact.c when a call of statement_timestamp is made, we calculate it based on the local start timestamp and the delta value: stmtStartTimestamp + GTMdeltaTimestamp Delta is itself calculated when received with this: GTMdeltaTimestamp = GTMxactStartTimestamp - stmtStartTimestamp So we basically we give the timestamp value received from GTM. The important point is linked to stmtStartTimestamp. This variable is constant inside a transaction, but it is changed when running statements out of a transaction block. I think it is important to keep algorithm the way it is done now. OK it complicates a little bit transaction timestamp calculation by using the delta twice. But the result is the same, and it permits to take into account both transaction timestamp and statement timestamp cases when calling statement_timestamp in xact.c. -- Michael Paquier http://michaelpq.users.sourceforge.net |