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).