5

I started to draw new polygons in a layer within an existing GeoPackage that I previously created.

However, after editing several layers, I sometimes (apart that it doesn't happen when editing one single layer, it looks like a random phenomena) cannot save the layer and I get the error:

Errors: ERROR: feature(s) not added.

Provider errors: 
  OGR error creating feature: failed to execute insert : database is locked

The polygons drawn are then lost, which is pretty frustrating.

I googled a lot and found this rather old fix which is apparently already applied in QGIS 3.12 (my version).

Any suggestion?

2
  • Same issue with 3.12.3 as well. – GeorgeC May 28 '20 at 23:57
  • I can also confirm that i got this message today, with QGIS 3.14 . I only edited one record, however it has a large number of vertices. – nr_aus Sep 1 '20 at 7:36
1

ok unfortunately I performed 2 different resolution activities, and im not sure which activity resolved the problem.

First Action - I had previously run a python script (outside of QGIS) which had completed, but it had used the Geopackage (a different table though). I simply closed this python console window (maybe the console or process that ran inside the console had locked the DB?)

Second action - In QGIS, i went to Database > DB Manager and 'Reconnected' the database. I then reloaded the layer inside of my QGIS session, made an edit and saved. all good.

So - whether it was the first or second action. not sure.

1

When you open a geopackage, a few hidden extra file appear next to it in the directory. That basically lock the file so that no other user can change it. While geopackage is a database, its limited to one user. In this case Python had a handle on the file. If python crashes, it can sometimes keep the handle on the file until you kill the process.

0

In QGIS open your layers, then in database manager make a connection with the geopackage, delete all the layers, it is going to be opened in your actual project, then export each one to the same geopackage, it's going to appear the new layer with another style, so I recommend you to save each style too. It works for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.