Re: Duplicate key violation on upsert

Поиск
Список
Период
Сортировка
От Matt Magoffin
Тема Re: Duplicate key violation on upsert
Дата
Msg-id DDC9F7A4-4145-4DDD-BBC4-06D931DA7BE0@msqr.us
обсуждение исходный текст
Ответ на Re: Duplicate key violation on upsert  (Adrian Klaver <adrian.klaver@aklaver.com>)
Ответы Re: Duplicate key violation on upsert
Список pgsql-general

On 23/03/2020, at 9:44 AM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
Is there a chance the BEFORE trigger functions are doing something that could be leading to the error?

In the error log is there a line with the actual values that failed?

The error log does not show the literal values, no. Here is a literal example from the logs:

2020-03-20 19:51:11 NZDT [15165]: [6-1] ERROR:  duplicate key value violates unique constraint "_hyper_1_1931_chunk_da_datum_x_acc_idx"
2020-03-20 19:51:11 NZDT [15165]: [7-1] CONTEXT:  SQL statement "INSERT INTO solardatum.da_datum(ts, node_id, source_id, posted, jdata_i, jdata_a, jdata_s, jdata_t)
                VALUES (ts_crea, node, src, ts_post, jdata_json->'i', jdata_json->'a', jdata_json->'s', solarcommon.json_array_to_text_array(jdata_json->'t'))
                ON CONFLICT (node_id, ts, source_id) DO UPDATE
                SET jdata_i = EXCLUDED.jdata_i,
                        jdata_a = EXCLUDED.jdata_a,
                        jdata_s = EXCLUDED.jdata_s,
                        jdata_t = EXCLUDED.jdata_t,
                        posted = EXCLUDED.posted
                RETURNING (xmax = 0)"
        PL/pgSQL function solardatum.store_datum(timestamp with time zone,bigint,text,timestamp with time zone,text,boolean) line 10 at SQL statement
2020-03-20 19:51:11 NZDT [15165]: [8-1] STATEMENT:  select * from solardatum.store_datum($1, $2, $3, $4, $5) as result

As for the BEFORE triggers, the solardatum.trigger_agg_stale_datum one does an INSERT into a different table and a SELECT from this same table. The _timescaledb_internal.insert_blocker one is part of the TimescaleDB extension which looks like it wouldn’t have an impact to this issue, but the source of that is


— m@

В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Could postgres12 support millions of sequences? (like 10 million)
Следующее
От: Don Seiler
Дата:
Сообщение: Re: Mixed Locales and Upgrading