-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Describe the bug
datapusher-plus/ckanext/datapusher_plus/jobs.py
Line 1056 in 7b8bc6f
| # truncate table to use copy freeze option and further increase |
Here, you note that truncate increases the speed that copy runs at. We're finding that with larger CSVs, the combination of truncate + a long running operation causes lock issues.
Truncate acquires an AccessExclusive lock, which essentially blocks all other queries, including select. This includes the select count(_id) from tbl that datastore's resource_fields runs .
This has the effect of blocking datastore_info or any datastore_search queries until the copy command terminates, which can be well over the time that the load balancer is willing to wait. Since we're (datastore) not takaing explicit nowait AccessShare locks prior to running queries, we just wait and wait and wait until the copy completes.
The PG documentation that you link to goes on to say:
However, this consideration only applies when wal_level is minimal as all commands must write WAL otherwise.
AFAIK, WAL Minimal isn't a common configuration for organizations interested in durable storage.
To Reproduce
Steps to reproduce the behavior:
- Upload a big CSV. OMM, 40Mb will cause a 100 sec copy command
- Run datastore_info, or possibly indexing, or other operations on that resource using datastore at that time.
- See select count(*) block till the copy is complete and committed.
This might be clearer if you upload enough to generate the view, then upload a new, huge CSV, and visit the view.