Article - CS295675
DataTable updates via AddOrUpdateDataTableEntry are not thread safe and can cause key collisions, DB deadlocks, or stuck threads in ThingWorx
Modified: 09-Jan-2020
Applies To
- ThingWorx Platform 7.4 to 8.4 SP2
Description
- Database deadlocks when updating ThingWorx Data Tables
- Frequent key collisions when updating Data Tables
- Repeatedly receiving high CPU alerts on ThingWorx server
- Error in database log for deadlocks:
2017-09-29 18:00:48 UTC:10.81.0.133(43894): [23973]:DETAIL: Process 23973 waits for ShareLock on transaction 1014855202; blocked by process 52285.
Process 52285 waits for ExclusiveLock on tuple (739135,1) of relation 75984 of database 75548; blocked by process 56309.
Process 56309 waits for ShareLock on transaction 1014305935; blocked by process 23973.
Process 23973: UPDATE data_table SET (entity_id, field_values, entity_key, location, source_id, source_type, tags, time, full_text) = ($1, $2, $3, $4, $5, $6, $7, $8, $9) WHERE entry_id = $10
Process 52285: UPDATE data_table SET (entity_id, field_values, entity_key, location, source_id, source_type, tags, time, full_text) = ($1, $2, $3, $4, $5, $6, $7, $8, $9) WHERE entry_id = $10
Process 56309: UPDATE data_table SET (entity_id, field_values, entity_key, location, source_id, source_type, tags, time, full_text) = ($1, $2, $3, $4, $5, $6, $7, $8, $9) WHERE entry_id = $10
Process 52285 waits for ExclusiveLock on tuple (739135,1) of relation 75984 of database 75548; blocked by process 56309.
Process 56309 waits for ShareLock on transaction 1014305935; blocked by process 23973.
Process 23973: UPDATE data_table SET (entity_id, field_values, entity_key, location, source_id, source_type, tags, time, full_text) = ($1, $2, $3, $4, $5, $6, $7, $8, $9) WHERE entry_id = $10
Process 52285: UPDATE data_table SET (entity_id, field_values, entity_key, location, source_id, source_type, tags, time, full_text) = ($1, $2, $3, $4, $5, $6, $7, $8, $9) WHERE entry_id = $10
Process 56309: UPDATE data_table SET (entity_id, field_values, entity_key, location, source_id, source_type, tags, time, full_text) = ($1, $2, $3, $4, $5, $6, $7, $8, $9) WHERE entry_id = $10
- Error in database logs for key collisions:
2018-06-16 08:25:33 EDT ERROR: duplicate key value violates unique constraint "entity_key_constraint"
2018-06-16 08:25:33 EDT DETAIL: Key (entity_key, entity_id)=(1, DT) already exists.
2018-06-16 08:25:33 EDT STATEMENT: INSERT INTO data_table (entity_id, field_values, entity_key, location, source_id, source_type, tags, time, full_text) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING entry_id
2018-06-16 08:25:33 EDT DETAIL: Key (entity_key, entity_id)=(1, DT) already exists.
2018-06-16 08:25:33 EDT STATEMENT: INSERT INTO data_table (entity_id, field_values, entity_key, location, source_id, source_type, tags, time, full_text) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING entry_id
This is a printer-friendly version of Article 295675 and may be out of date. For the latest version click CS295675