在插入相同数据两次时,我有时会在日志中看到以下错误:
error: attempted to delete invisible tuple
at Connection.parseE (/home/ubuntu/vacation-server/node_modules/pg/lib/connection.js:554:11)
at Connection.parseMessage (/home/ubuntu/vacation-server/node_modules/pg/lib/connection.js:381:17)
at Socket.<anonymous> (/home/ubuntu/vacation-server/node_modules/pg/lib/connection.js:117:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:548:20)
我的查询如下:
INSERT INTO google_places (
id,
data,
geographic_coordinates
) VALUES (
$1,
$2,
ST_GeomFromText('POINT(-118.440908 34.063246)', 4326)
)
ON CONFLICT (id) DO UPDATE
SET data = EXCLUDED.data,
geographic_coordinates = EXCLUDED.geographic_coordinates,
date_updated = CURRENT_TIMESTAMP
RETURNING *
任何想法?
答案 0 :(得分:4)
在9.5.5之前的版本中,挂起TOASTed数据可能会在某些特定情况下引发此异常。我使用基于函数索引的冲突键(特别是ON CONFLICT (md5(myblob)) DO UPDATE
)遇到了它,但它也是同样的错误。
This thread具有完整的详细信息。该错误已在9.5.5和9.6中修复,但我不知道Postgres早期版本的任何简单的解决方法。我最终不得不使用旧式的CTE upsert。