[GIS] How does Spatialite handle concurrent access

qgisspatialite

I understand that Spatialite is meant to be used by a single user/machine at a time. However if the data is stored on server, there is no guarantee that someone on another machine will not also open the same database and use it. Has anyone got any experience with how QGIS and spatialite react to being in a multiuser environment. In most cases, the layer would be a read only layer. QGIS allows multiple people to read the same shapefiles, which is a similar situation. What happens if multiple people have concurrent editing sessions open?

Best Answer

SQLite operates in a last edit wins model, which leads to issues with more weight than write blocks. There is no editing session tracking in the QGIS/SQLite relationship. So, even if you did get a single writer block (SQLITE_BUSY) QGIS will simply fail to edit and just return an error then submit the change again.

The below discusses the handling of this type of event, and how QGis handles the resubmit.

https://github.com/qgis/QGIS/blob/a3447dd9a346f6d5e08451b7c5666a37046435bc/src/core/spatialite/headers/spatialite/sqlite3.h#L1881-L1943

Related Question