Closed indirectlylit closed 4 years ago
Looks like the get_or_create is trying to pre-emptively be able to write even if it might not need to? (at this point, the instance ID should already be defined).
Does it take some time to return, or does it return immediately?
I don't think it's actually to do with the instance ID not being defined, I think it could be possible for this to happen even with it being a read, given the strict read isolation that is necessary in order to maintain snapshot consistency for Morango operations. We recently increased the read isolation level for Postgres, as it defaults to a low level of consistency. SQLite already defaults to the highest level of consistency based on how it's architected, so nothing changed there.
The main thing going on here is the import of a massive set of demo facility data. The transactions while doing a transfer should be short enough, but the serialization/deserialization stages likely involve some very long-running transactions. Would be good to know whether this would have occurred in previous versions, or if there's an interaction with the changes recently made to the InstanceID stuff.
If it's just being read then it shouldn't get a database locked error though, that's why I was wondering exactly what might be happening internally. It should only error that the database is locked when the large write transaction is open for syncing, and then the call to get the instance ID ends up in a write to the DB.
I split up the push and pull sync operations into separate client classes with consistent API's so we can use the write lock on the sensitive portion(s) only; push initialization and pull finalization. Here's the WIP PR, still need to add a few more tests https://github.com/learningequality/morango/pull/85
Closed with above merges.
Observed behavior
While running facility import or export, trying to access the device info page throws a 500 error:
Expected behavior
Able to view device info while import/export is occurring
User-facing consequences
broken functionality and unexpected error, or possibly finding a workaround for more gracefully handling this situation if locking is innevitable
Errors and logs
Steps to reproduce
kolibri-beta
This was observed both on the importing device and the exporting device.
Context
0.14.0 beta 3