pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #16072: Two transaction to delete all data, The result is not hopeful
2+ messages / 2 participants
[nested] [flat]

* BUG #16072: Two transaction to delete all data, The result is not hopeful
@ 2019-10-23 06:29  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2019-10-23 06:29 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: zhuqiangwei010@hotmail.com

The following bug has been logged on the website:

Bug reference:      16072
Logged by:          qiangwei zhu
Email address:      zhuqiangwei010@hotmail.com
PostgreSQL version: 10.5
Operating system:   &quot;PostgreSQL 10.5 on x86_64-pc-linux-gnu, compiled
Description:        

my test table struct is:
create table test(
  f1 int
)

test table data is:
f1
---------------
1
1
1
1
1

I open two query analyzer,
trans A:

begin TRANSACTION;
delete from test;
INSERT into test(f1)
values(1)


trans B:
begin TRANSACTION;
delete from test;

then commit transA, last commit transB

why in test table has 1 rows at last?
sqlserver 、oracle、mysql database,use same test solution, there was no data
in test table at last.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #16072: Two transaction to delete all data, The result is not hopeful
@ 2019-10-23 06:39  Guillaume Lelarge <guillaume@lelarge.info>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Guillaume Lelarge @ 2019-10-23 06:39 UTC (permalink / raw)
  To: PG Bug reporting form <noreply@postgresql.org>; +Cc: pgsql-bugs@lists.postgresql.org; zhuqiangwei010@hotmail.com

Hello,

Le mer. 23 oct. 2019 à 08:29, PG Bug reporting form <noreply@postgresql.org>
a écrit :

> The following bug has been logged on the website:
>
> Bug reference:      16072
> Logged by:          qiangwei zhu
> Email address:      zhuqiangwei010@hotmail.com
> PostgreSQL version: 10.5
> Operating system:   &quot;PostgreSQL 10.5 on x86_64-pc-linux-gnu, compiled
> Description:
>
> my test table struct is:
> create table test(
>   f1 int
> )
>
> test table data is:
> f1
> ---------------
> 1
> 1
> 1
> 1
> 1
>
> I open two query analyzer,
> trans A:
>
> begin TRANSACTION;
> delete from test;
> INSERT into test(f1)
> values(1)
>
>
> trans B:
> begin TRANSACTION;
> delete from test;
>
> then commit transA, last commit transB
>
> why in test table has 1 rows at last?
> sqlserver 、oracle、mysql database,use same test solution, there was no data
> in test table at last.
>
>
I suppose you're in the isolation level "read commited" as it's the
default. With this level, the database snapshot is made when the query
starts its execution. When the DELETE started its execution on transaction
B, it didn't know about the value inserted during transaction A as the
latter wasn't commited. The DELETE was waiting for a lock on the rows to
delete, but the database snapshot already happened. So, when it finally got
the locks, it only tried to delete rows existing before the beginning of
transaction A, hence without the latest inserted row.

Doesn't look like a bug to me. Seems to be working as intended.


-- 
Guillaume.

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2019-10-23 06:39 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23 06:29 BUG #16072: Two transaction to delete all data, The result is not hopeful PG Bug reporting form <noreply@postgresql.org>
2019-10-23 06:39 ` Guillaume Lelarge <guillaume@lelarge.info>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox