Re: Tracking row updates - race condition

From: Harald Fuchs <use_reply_to(at)protecting(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Tracking row updates - race condition
Date: 2005-03-21 23:16:14
Message-ID: puwts03801.fsf@srv.protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <423F09CF(dot)2030008(at)alexandcarmen(dot)com>,
Alex Adriaanse <alex(at)alexandcarmen(dot)com> writes:

> I think that would greatly decrease the chances of a race condition
> occurring, but I don't think it'd solve it. What if 150 other
> revisions occur between a row update and its corresponding commit?

How about the following:

* Use a TIMESTAMP rather than a SERIAL
* Set this timestamp to NULL in your INSERT/UPDATE trigger
* Use a cron job to set the timestamp to current_timestamp when it's NULL

This way the client would lag behind somewhat, depending on the cron
job frequency, but it should not miss a change.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ed L. 2005-03-21 23:30:45 Measuring Query Performance
Previous Message David Parker 2005-03-21 22:29:35 create or replace trigger?