use real time for events
NOW() is time of transaction start. For long transaction, there could be race and some other transactions which ended earlier can have newer events. clock_timestamp returns real time (changes during transaction), so it should be better for this case. Fixes: https://pagure.io/koji/issue/1747
This commit is contained in:
parent
8172bff053
commit
b54c32af1a
2 changed files with 18 additions and 2 deletions
|
|
@ -7,12 +7,12 @@ BEGIN WORK;
|
|||
-- in the event that the system clock rolls back, event_ids will retain proper sequencing
|
||||
CREATE TABLE events (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
time TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
time TIMESTAMP NOT NULL DEFAULT clock_timestamp()
|
||||
) WITHOUT OIDS;
|
||||
|
||||
-- A function that creates an event and returns the id, used as DEFAULT value for versioned tables
|
||||
CREATE FUNCTION get_event() RETURNS INTEGER AS '
|
||||
INSERT INTO events (time) VALUES (''now'');
|
||||
INSERT INTO events (time) VALUES (clock_timestamp());
|
||||
SELECT currval(''events_id_seq'')::INTEGER;
|
||||
' LANGUAGE SQL;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue