Database Locking Issues
While testing the context data loading logic, it was noted that numerious attributes were being missed. The operation happens on the same row in the database. This caused Postgres to throw locking errors.
At first this was thought to be an autocommit issue. However recent Postgres versions have this set on on by default.
Possible Solutions
Convert SQL insertions from asynchronous to synchonous.
Build a multi-insert statement and make only one query to the database.
I'm personlly in favour of the later as it would be more performant to run one transaction instead of many.
Tasks
[x] BCTW Layers - Move loop outside of database logic and into a string building operation
[x] BCTW Layers - Use the SQL building library to safely insert variables into the sql string.
[ ] Local Layers - Move loop outside of database logic and into a string building operation
[ ] Local Layers - Use the SQL building library to safely insert variables into the sql string.
The BCGW layers are now being inserted in one long SQL statement.
The local layer queries were not causing locking issues... So the logic was kept the same.
Database Locking Issues While testing the context data loading logic, it was noted that numerious attributes were being missed. The operation happens on the same row in the database. This caused Postgres to throw locking errors.
At first this was thought to be an
autocommit
issue. However recent Postgres versions have this set on on by default.Possible Solutions
I'm personlly in favour of the later as it would be more performant to run one transaction instead of many.
Tasks