Bug report #13699
Spatialite database file remains locked after layers removed.
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Data Provider/SpatiaLite | ||
Affected QGIS version: | 2.10.1 | Regression?: | No |
Operating System: | Linux / Windows | Easy fix?: | No |
Pull Request or Patch supplied: | No | Resolution: | worksforme |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 21728 |
Description
When Spatialite layers are removed, the connection to the database remains open. This prevents renaming or deleting of the file. The lock remains in place for around 45 to 60 seconds, in most cases.
Example: * Layer > Add Layer > Add Spatialite Layer * Select from database and add * Right click Layer > Remove * Database file is locked
This behaviour also occurs with Python, which gives ‘WindowsError’ in Windows 7, or ‘OSError’ in Xubuntu 14.04.
The Linux terminal gets:
mv: cannot move ‘test.sqlite’ to ‘test2.sqlite’: Text file busy
Further information can be obtained from the following command in Linux:
lsof -r5 +D /path/to/working/directory/
This shows open files every 5 seconds. Opening a layer creates 2 connections to the file, both owned by qgis.bin. One is read/write, the other is read only. On removing the layers, the read only connection remains for around a minute, after which the file can be moved. Sometimes (on Windows) the connection requires a restart of QGIS, or even a reboot, to be cleared.
The behaviour seems similar to #12938, which affects the DB Manager and resulted in it adding extra layers to the registry when spatialite layers were previewed. However, no extra layers are added in this case. Running the DB Manager with `lsof` active shows that it also creates connections that are not closed.
History
#1 Updated by Giovanni Manghi about 9 years ago
- Status changed from Open to Feedback
Just tested on master on linux and windows and cannot confirm, could you give it a try and report back? thanks!
#2 Updated by John Stevenson about 9 years ago
Tested on Master 9b192d4 (Windows) and 2.12 (Linux) and behaviour is the same.
Have attached simple spatialite file, created in QGIS, as example. Behaviour happens with all spatialite versions.
Test:
- Add test_points layer from test.sqlite database as a layer
- Remove the layer
- Try to rename or delete the sqlite file in the operating system.
Result:
- "The action can't be completed because the file is open in qgis-dev-bin.exe"
After some time (30-60 seconds), the lock is released.
#3 Updated by Giovanni Manghi about 9 years ago
John Stevenson wrote:
Tested on Master 9b192d4 (Windows) and 2.12 (Linux) and behaviour is the same.
Have attached simple spatialite file, created in QGIS, as example. Behaviour happens with all spatialite versions.
attachment missing.
#5 Updated by Giovanni Manghi about 9 years ago
John Stevenson wrote:
Tested on Master 9b192d4 (Windows) and 2.12 (Linux) and behaviour is the same.
Have attached simple spatialite file, created in QGIS, as example. Behaviour happens with all spatialite versions.
Test:
- Add test_points layer from test.sqlite database as a layer
- Remove the layer
- Try to rename or delete the sqlite file in the operating system.
Result:
- "The action can't be completed because the file is open in qgis-dev-bin.exe"
After some time (30-60 seconds), the lock is released.
can't confirm, on both Linux (ubuntu 14.04) and Windows (7).
#6 Updated by Giovanni Manghi about 9 years ago
- Resolution set to worksforme
- Status changed from Feedback to Closed
closing for lack of feedback.