Closed Shylpx closed 2 years ago
This pull request has been linked to Shortcut Story #161683: Duplicate key value on cdb_tablemetadata table after INSERT or COPY from due to CDB_TableMetadata_Trigger.
Closing, more information in https://github.com/CartoDB/cartodb/pull/16346#issuecomment-1309095799
Resources
Context
cdb_tablemetadata
the name of the table and the last time it was updated:updated
section). If that section returnsNULL
, it means that there isn't a row for that table, and we insert a new one. But there is a remote chance of race condition when two inserts are made simultaneously and the row doesn't exist yet: if both inserts try to update the row, they will both try to insert the record into the table. The first one will work, but the second one will fail, since the table's name is the primary key.duplicate key value violates unique constraint \"cdb_tablemetadata_pkey\"
.Changes
UNIQUE_VIOLATION
exception and retrying the update.