3liz / py-qgis-server

QGIS embbeded WMS/WFS/WCS asynchronous scalable http server
https://docs.3liz.org/py-qgis-server
Mozilla Public License 2.0
68 stars 16 forks source link

Project modified timestamp mismatch when loaded from postgres #28

Closed AsgerPetersen closed 3 years ago

AsgerPetersen commented 3 years ago

I have had problems loading projects from postgres. I believe I have tracked it down to a problem with these checks https://github.com/3liz/py-qgis-server/blob/5538b29893596f2c318565c02bb86a9b46b21a04/pyqgisserver/qgscache/handlers/postgres_handler.py#L140-L146

If I log the timestamps like this

            project_modified = project.lastModified()
            if modified_time != datetime.fromtimestamp(
                project_modified.toSecsSinceEpoch()
            ):
                LOGGER.error(
                    "modified_time [%s] does not match project.lastModified [%s] converted datetime [%s]",
                    modified_time,
                    project_modified,
                    datetime.fromtimestamp(project_modified.toSecsSinceEpoch()),
                )
                raise cachemngr.UnreadableResourceError()

I get this in my log output:

modified_time [2021-06-29 12:12:38.739532] does not match project.lastModified [PyQt5.QtCore.QDateTime(2021, 6, 29, 12, 12, 38, 740)] converted datetime [2021-06-29 12:12:38]

It seems like comparing the timestamps like this is very fragile.

dmarteau commented 3 years ago

Oops, this is a badly tested check: it is removed in 732410084f1838c5a5e5c84f0f4c3041b7b11436. You may test the latest rc images on Docker hub.

dmarteau commented 3 years ago

Test removed in 1.7.1