[gdal-dev] Cannot delete layer - table is locked

a.furieri at lqt.it a.furieri at lqt.it
Mon Sep 18 08:01:21 PDT 2017


On Mon, 18 Sep 2017 12:25:47 +1000, Nik Sands wrote:
> Hi GDAL devs,
>
> What is the correct way in GDAL/OGR to release locks on the layer (in
> this case the SQLite tables in a geopackage) so that the layer can be
> deleted from the data source?
>
> My issue is that after writing new features to a layer, I may want to
> delete the layer completely, but when I do so using:
>
> 	OGR_DS_DeleteLayer()
>
> I get errors like:
>
> ERROR 1: sqlite3_exec(DROP TABLE
> "rtree_Track_2017_09_18_12_14_09_Line_geom") failed: database table 
> is
> locked
> ERROR 1: sqlite3_exec(DROP TABLE 'Track_2017_09_18_12_14_09_Line')
> failed: database table is locked
>
> What is the correct way to handle this situation, so that I can add
> features to a layer, but then delete it?
>

Hi Nik,

SQLite always refuses to DROP any table still being required
by an ongoing SQL query; in this case a SQLITE_LOCKED error
will be raised, corresponding to the message "database table
is locked".

useful reading:
https://stackoverflow.com/questions/30081581/sqlite-error-database-is-locked-when-using-sqlite3-command-line

bye Sandro


More information about the gdal-dev mailing list