Re: How to get updated order data - Mailing list pgsql-general

From Laurenz Albe
Subject Re: How to get updated order data
Date
Msg-id 54be8b47fad3440b377ae2e53d02b5ca60a6c2a7.camel@cybertec.at
Whole thread Raw
In response to How to get updated order data  (Andrus <kobruleht2@hot.ee>)
Responses Re: How to get updated order data  (Magnus Hagander <magnus@hagander.net>)
List pgsql-general
On Thu, 2022-04-07 at 16:16 +0300, Andrus wrote:
> Orders are in table
> 
>          create table order ( 
>            dokumnr int primary key,
>            packno char(10)
>            );
>         insert into order dokumnr values (123);
> 
>  One user sets pack number using
> 
>      update order set packno='Pack1' where dokumnr=123
> 
>  3 seconds later other user retrieves pack number using
> 
>      select packno from order where dokumnr=123
> 
>  However, other user gets null value, not Pack1 as expected. After some time later, correct value Pack1 is returned.
> 
>  How to get updated data from other user immediately?
>  3 seconds is long time, it is expected that select suld retrieve update data.
> 
>  There are lot of transactions running concurrently. Maybe update command is not written to database if second user
retrievesit.
 
> 
>  How to flush orders table so that current results are returned for second user select ?
> 
>  Using 
>   PostgreSQL 13.2, compiled by Visual C++ build 1914, 64-bit
>   and psqlODBC driver.

That cannot happen, unless

a) the UPDATE runs in a transaction that hasn't been committed

b) the SELECT is running on a standby server, and there is replication lag

Yours,
Laurenz Albe

-- 
Cybertec | https://www.cybertec-postgresql.com




pgsql-general by date:

Previous
From: Vijaykumar Jain
Date:
Subject: Re: Could not read block 0 in file
Next
From: Jan Wieck
Date:
Subject: Re: What have I done!?!?!? :-)