Bug report #14196

QGIS Server sending UPDATE... WHERE NULL to postgis in a WFS layer

Added by Aitor Gil over 4 years ago. Updated over 3 years ago.

Status:Closed
Priority:High
Assignee:-
Category:QGIS Server
Affected QGIS version:2.12.2 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:not reproducable
Crashes QGIS or corrupts data:No Copied to github as #:22198

Description

Hi,

I am running a Windows Server 2012 server.
PostgreSQL 9.3.5, 64-bit
POSTGIS 2.1.3
QGIS Server 2.6.1-2
QGIS Desktop 2.8.3 and 2.12

I am using a Microsoft Surface Pro 4 tablet using QGIS Desktop 2.12 to edit some layers stored in the Postgresql database. The layers in the tablet are WFS layers served by QGIS Server.

When I toogle editing after inserting some data in the layer to force the data to be sent and stored in the server sometimes the update is not being done in the Database.

I can see that the POST http request arrives to the server ok, but sometimes I can't see a commit (update) in the database and some other times it works ok and does the commit.

In QGIS Server's logs I can see (I updated 3 features' data in QGIS Desktop):

//QGIS SERVER RECEIVED HTTP POST FROM QGIS DESKTOP

[4852][11:11:19] ********************new request***************
[4852][11:11:19] remote ip: 192.168.144.20
[4852][11:11:19] CONTENT_TYPE: text/xml
[4852][11:11:19] HTTP_USER_AGENT: Mozilla/5.0 QGIS/2.8.2-Wien
[4852][11:11:19] MAP:D:\\OSGeo4W\\apps\\qgis\\bin\\alumbrado\\alumbrado.qgs
[4852][11:11:19] REQUEST:Transaction
[4852][11:11:19] REQUEST_BODY:<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" service="WFS" xsi:schemaLocation="http://www.qgis.org/gml http://eudala2.getxo.net/qgis/qgis_mapserv.fcgi.exe?map=D:\\OSGeo4W\\apps\\qgis\\bin\\alumbrado\\alumbrado.qgs&amp;SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=getxo_alumbrado_arquetas_registros_cajas&amp;SRSNAME=EPSG:23030" xmlns:gml="http://www.opengis.net/gml"><Update xmlns="http://www.opengis.net/wfs" typeName="getxo_alumbrado_arquetas_registros_cajas"><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">id_modelo</Name><Value xmlns="http://www.opengis.net/wfs">0</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">alumbrado</Name><Value xmlns="http://www.opengis.net/wfs">t</Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="getxo_alumbrado_arquetas_registros_cajas.3"/></Filter></Update><Update xmlns="http://www.opengis.net/wfs" typeName="getxo_alumbrado_arquetas_registros_cajas"><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">id_modelo</Name><Value xmlns="http://www.opengis.net/wfs">0</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">alumbrado</Name><Value xmlns="http://www.opengis.net/wfs">t</Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="getxo_alumbrado_arquetas_registros_cajas.4"/></Filter></Update><Update xmlns="http://www.opengis.net/wfs" typeName="getxo_alumbrado_arquetas_registros_cajas"><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">tipo</Name><Value xmlns="http://www.opengis.net/wfs">A</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">tipo_tapa</Name><Value xmlns="http://www.opengis.net/wfs">B</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">estado</Name><Value xmlns="http://www.opengis.net/wfs">D</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">p_tierra_tipo_electrodo_tierra</Name><Value xmlns="http://www.opengis.net/wfs">O</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">p_tierra_tipo_union_electrodo_tierra</Name><Value xmlns="http://www.opengis.net/wfs">N</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">p_tierra_estado_union_tierra</Name><Value xmlns="http://www.opengis.net/wfs">D</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">tipo_intervencion</Name><Value xmlns="http://www.opengis.net/wfs">OTR</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">m_codcalle</Name><Value xmlns="http://www.opengis.net/wfs">20</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">id_modelo</Name><Value xmlns="http://www.opengis.net/wfs">0</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">alumbrado</Name><Value xmlns="http://www.opengis.net/wfs">t</Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="getxo_alumbrado_arquetas_registros_cajas.5"/></Filter></Update></Transaction>
[4852][11:11:19] SERVICE:WFS
[4852][11:11:19] SRSNAME:EPSG:23030
[4852][11:11:19] VERSION:1.0.0
[4852][11:11:22] Request finished in 2977 ms

Ok, when I look into PostgreSQL logs I can see that the update has a WHERE NULL clause, which updates nothing..

//POSTGRESQL UPDATE QUERIES

2016-01-29 11:11:22 CET LOG:  00000: sentencia: UPDATE "public"."getxo_alumbrado_arquetas_registros_cajas" SET "id_modelo"=0,"alumbrado"='t' WHERE NULL
2016-01-29 11:11:22 CET UBICACIÓN:  exec_simple_query, src\\backend\\tcop\\postgres.c:890
2016-01-29 11:11:22 CET LOG:  00000: sentencia: UPDATE "public"."getxo_alumbrado_arquetas_registros_cajas" SET "id_modelo"=0,"alumbrado"='t' WHERE NULL
2016-01-29 11:11:22 CET UBICACIÓN:  exec_simple_query, src\\backend\\tcop\\postgres.c:890
2016-01-29 11:11:22 CET LOG:  00000: sentencia: UPDATE "public"."getxo_alumbrado_arquetas_registros_cajas" SET "tipo"='A',"tipo_tapa"='B',"estado"='D',"p_tierra_tipo_electrodo_tierra"='O',"p_tierra_tipo_union_electrodo_tierra"='N',"p_tierra_estado_union_tierra"='D',"tipo_intervencion"='OTR',"m_codcalle"='20',"id_modelo"=0,"alumbrado"='t' WHERE NULL

I can see in the POST data that QGIS Server knows which feature needs to be updated using de internal "fid" number. My layer, on the other hand, has "id" field as primary key. Somewhere when it does the mapping from QGIS internal fid to my layer's id it's getting lost and adds WHERE null to the query instead of adding where id=1510.

The funny thing is that they have been working for 40 days and hey only got this problem once, but since last week they have had this problem every day...Since then sometimes works and sometimes not. I resend the POST http request from client ysing Fiddles proxy and the same HTTP post sometimes works and other times don't.

I tested it in QGIS Desktop 2.8, 2.10 and 2.12 and happens in all of them (QGIS Server is 2.6.1 I think). I also tested it with different layers with same result.

I don't know if there is a bug or there is some kind of config to the layer I am not doing properly in server...

Regards,


Related issues

Duplicated by QGIS Application - Bug report #14715: QGIS Server sending sometimes UPDATE… WHERE NULL to postg... Closed 2016-04-21

History

#1 Updated by Jürgen Fischer about 4 years ago

  • Category set to QGIS Server

#2 Updated by Jürgen Fischer about 4 years ago

  • Status changed from Open to Feedback

What kind of keys is that layer using? Is suppose it is using a string or a composite key - for those a temporary map of integer keys mapped to the actual key values is produces when features are fetches. The map is not persistent and contains only retrieved features. If the layer is dropped from the server's layer cache to make room for other layers, that map is lost. When there are updates later the layer is recreated with a fresh map and when the temporary feature id from the WFS request is not found in the map NULL is used instead.

#3 Updated by Giovanni Manghi over 3 years ago

  • Resolution set to not reproducable
  • Status changed from Feedback to Closed

Closing for lack of feedback, please reopen if necessary.

Also available in: Atom PDF