pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #15946: "duplicate key" error on ANALYZE of table partitions in transaction
4+ messages / 3 participants
[nested] [flat]
Commits from this thread:
2019-08-10 cabe0f298e 6ce0366be2 ceb850d4a3 Fix "ANALYZE t, t" inside a transaction block.
* BUG #15946: "duplicate key" error on ANALYZE of table partitions in transaction
@ 2019-08-10 12:45 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 4+ messages in thread
From: PG Bug reporting form @ 2019-08-10 12:45 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: ladayaroslav@yandex.ru
The following bug has been logged on the website:
Bug reference: 15946
Logged by: Yaroslav Schekin
Email address: ladayaroslav@yandex.ru
PostgreSQL version: 11.5
Operating system: Any
Description:
Running this:
-----
BEGIN TRANSACTION;
CREATE TABLE sg (
id bigint NOT NULL,
sc_fk bigint,
geo_id bigint,
sl smallint NOT NULL,
a date NOT NULL,
o boolean NOT NULL
)
PARTITION BY RANGE (o, sl, a);
CREATE TABLE sg_19_01_d PARTITION OF sg FOR VALUES FROM (false, '5',
'2019-01-01') TO (false, '5', '2019-02-01');
CREATE TABLE sg_19_02_d PARTITION OF sg FOR VALUES FROM (false, '5',
'2019-02-01') TO (false, '5', '2019-03-01');
CREATE TABLE sc (
id bigint,
a date NOT NULL,
sl smallint NOT NULL,
o boolean NOT NULL
)
PARTITION BY RANGE (o, sl, a);
CREATE TABLE sc_19_01_d PARTITION OF sc FOR VALUES FROM (false, '5',
'2019-01-01') TO (false, '5', '2019-02-01');
CREATE TABLE sc_19_02_d PARTITION OF sc FOR VALUES FROM (false, '5',
'2019-02-01') TO (false, '5', '2019-03-01');
INSERT INTO sg_19_01_d(id, sc_fk, geo_id, sl, a, o)
SELECT n, n, 0, 5, '2019-01-01', false
FROM generate_series(1, 1000) AS g(n);
INSERT INTO sg_19_02_d(id, sc_fk, geo_id, sl, a, o)
SELECT n, n, 0, 5, '2019-02-01', false
FROM generate_series(1, 1000) AS g(n);
INSERT INTO sc_19_01_d(id, a, sl, o)
SELECT n, '2019-01-01', 5, false
FROM generate_series(1, 1000) AS g(n);
INSERT INTO sc_19_02_d(id, a, sl, o)
SELECT n, '2019-02-01', 5, false
FROM generate_series(1, 1000) AS g(n);
ANALYZE sg_19_01_d, sc_19_02_d, sc_19_01_d, sc_19_02_d;
-----
Throws this error:
ERROR: duplicate key value violates unique constraint
"pg_statistic_relid_att_inh_index"
DETAIL: Key (starelid, staattnum, stainherit)=(61056, 1, f) already exists.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #15946: "duplicate key" error on ANALYZE of table partitions in transaction
@ 2019-08-10 14:23 Tom Lane <tgl@sss.pgh.pa.us>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2019-08-10 14:23 UTC (permalink / raw)
To: ladayaroslav@yandex.ru; +Cc: pgsql-bugs@lists.postgresql.org
PG Bug reporting form <noreply@postgresql.org> writes:
> Running this:
> ...
> Throws this error:
> ERROR: duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index"
> DETAIL: Key (starelid, staattnum, stainherit)=(61056, 1, f) already exists.
Hm, you don't need all the fancy partitioning stuff:
regression=# create table t as select generate_series(1,10) x;
SELECT 10
regression=# begin;
BEGIN
regression=# analyze t, t;
ERROR: duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index"
DETAIL: Key (starelid, staattnum, stainherit)=(35836, 1, f) already exists.
It appears to work fine without the BEGIN:
regression=# analyze t, t;
ANALYZE
but then
regression=# begin;
BEGIN
regression=# analyze t, t;
ERROR: tuple already updated by self
I think the conclusion is that if we aren't using per-table
transactions we'd better do a CommandCounterIncrement between
tables in vacuum()'s loop.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #15946: "duplicate key" error on ANALYZE of table partitions in transaction
@ 2019-08-13 17:35 naveen mahadevuni <nmahadevuni@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: naveen mahadevuni @ 2019-08-13 17:35 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: ladayaroslav@yandex.ru; pgsql-bugs@lists.postgresql.org
hi Tom,
I would like to start contributing to postgres, would like to fix this one
if it hasn't already been done.
Thanks,
Naveen
On Sat, Aug 10, 2019 at 7:53 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> PG Bug reporting form <noreply@postgresql.org> writes:
> > Running this:
> > ...
> > Throws this error:
> > ERROR: duplicate key value violates unique constraint
> "pg_statistic_relid_att_inh_index"
> > DETAIL: Key (starelid, staattnum, stainherit)=(61056, 1, f) already
> exists.
>
> Hm, you don't need all the fancy partitioning stuff:
>
> regression=# create table t as select generate_series(1,10) x;
> SELECT 10
> regression=# begin;
> BEGIN
> regression=# analyze t, t;
> ERROR: duplicate key value violates unique constraint
> "pg_statistic_relid_att_inh_index"
> DETAIL: Key (starelid, staattnum, stainherit)=(35836, 1, f) already
> exists.
>
> It appears to work fine without the BEGIN:
>
> regression=# analyze t, t;
> ANALYZE
>
> but then
>
> regression=# begin;
> BEGIN
> regression=# analyze t, t;
> ERROR: tuple already updated by self
>
> I think the conclusion is that if we aren't using per-table
> transactions we'd better do a CommandCounterIncrement between
> tables in vacuum()'s loop.
>
> regards, tom lane
>
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #15946: "duplicate key" error on ANALYZE of table partitions in transaction
@ 2019-08-13 18:52 Tom Lane <tgl@sss.pgh.pa.us>
parent: naveen mahadevuni <nmahadevuni@gmail.com>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2019-08-13 18:52 UTC (permalink / raw)
To: naveen mahadevuni <nmahadevuni@gmail.com>; +Cc: ladayaroslav@yandex.ru; pgsql-bugs@lists.postgresql.org
naveen mahadevuni <nmahadevuni@gmail.com> writes:
> I would like to start contributing to postgres, would like to fix this one
> if it hasn't already been done.
Already done -
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cabe0f298ea7efade11d8171c617e6689...
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2019-08-13 18:52 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-08-10 12:45 BUG #15946: "duplicate key" error on ANALYZE of table partitions in transaction PG Bug reporting form <noreply@postgresql.org>
2019-08-10 14:23 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-08-13 17:35 ` naveen mahadevuni <nmahadevuni@gmail.com>
2019-08-13 18:52 ` Tom Lane <tgl@sss.pgh.pa.us>
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