We are inserting rows in a PostgreSQL database using 1000 rows transaction/commits on a Pentaho-spoon transformation.
The table has several fields/constraints as foreign keys, i.e. customer_id must exist on customer table and similars.
From time to time we get a deadlock error ...
ERROR: se ha detectado un deadlock
Detail: El proceso 29996 espera ShareLock en transacción 6643574; bloqueado por proceso 31826.
El proceso 31826 espera ShareLock en transacción 6643573; bloqueado por proceso 29996.
Hint: Vea el registro del servidor para obtener detalles de las consultas.
Where: sentencia SQL: «SELECT 1 FROM ONLY "public"."customer_table" x WHERE "id" OPERATOR(pg_catalog.=) $1 FOR SHARE OF x»
We didn't expect our inserts to block the other tables. The only reason I can imagine is to be sure the customer record is not deleted during the transaction elapsed time.
As we are pretty sure no customer record will be deleted (no way our users can do that), is there any way to avoid the shared lock?
Even if ther is not, I would appreciate any light on what is happening :)
Thks