[QGIS-Developer] Tackling Postgis layers connection recover
Nyall Dawson
nyall.dawson at gmail.com
Mon Feb 4 14:32:39 PST 2019
On Tue, 5 Feb 2019 at 05:54, Timothé Perez <timothe at pragma-innovation.fr> wrote:
>
> Hello qgis-devs,
>
> This is my first message here and first contribution to QGIS, so I thank you in advance for being indulgent and do not hesitate to correct me on any mistake I will make.
> I didn't want to jump right into proposing my patch "as is" in a PR as I'm new to this project, so first I wanted to discuss about it to make sure I got it right.
>
> Here's a recap of what I have found so far (sorry if it's a bit long):
>
> I'm using QGIS 3.4 with a PostgreSQL database to store layers and I'm facing the same issue as described in https://issues.qgis.org/issues/20170 : unrecoverable PostgreSQL connections.
>
> I have cloned the repo and started to dig, as it is really annoying because it forces you to abandon your changes and close and reopen your project.
Upfront, thanks for the great attitude. This is one of the MOST
effective ways to get bugs fixed... rolling up your sleeves and fixing
them yourself!
> To reproduce the problem, the simplest way is to spin a local PostgreSQL database with postgis and create a table with just a serial and a geometry:
> CREATE TABLE foo (id serial primary key, geometry GEOMETRY(POINT, 4326));
>
> Open it in QGIS, create several features, save them then simply restart the PostgreSQL service so that all connections are forced to be closed.
> QGIS logs will display that the connections to PostgreSQL were lost but recovered and features will still be accessible.
>
> However if I start editing the layer by adding a feature and then call save, it will fail:
>
> 2019-02-04T19:11:30 CRITICAL Layer foo : PostGIS error while adding features: FATAL: terminating connection due to administrator command
> la connexion au serveur a été coupée de façon inattendue
> Le serveur s'est peut-être arrêté anormalement avant ou durant le
> traitement de la requête.
>
> 2019-02-04T19:11:30 WARNING Commit errors : Could not commit changes to layer foo
> 2019-02-04T19:11:34 CRITICAL Layer foo : PostGIS error while adding features: no result buffer
> 2019-02-04T19:11:34 WARNING Commit errors : Could not commit changes to layer foo
>
> My only option is to cancel my edits and reload the project to regain full access to the db.
>
> So in fact this problem has 2 causes: (time to dig in the C++ code)
>
*snip*
>
> I am willing to propose a PR if my fixes make sense and are acceptable, this will fix an annoying issue.
They both sound reasonable to me, and yes, valuables fixes for an
annoying issues! Looking forward to the PRs! (One request: please file
these as two separate PRs, so both fixes can be discussed and reviewed
independently.)
Nyall
More information about the QGIS-Developer
mailing list