Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PostGIS as alternative data source to Overpass #10

Merged
merged 2 commits into from
Jul 23, 2023

Conversation

steinbro
Copy link
Member

To use, just set the --backend-url to a postgres:// URL. For example, if you're running the docker-compose setup I added to the Openscape repo a while back, use postgres://postgres:secret@localhost:5432/osm. (You'd also need to specify an alternate --port in this case, since the original tile server in that docker-compose setup also runs on 8080.)

@Oliver2213 if you are spinning up a PostGIS data source, please test this.

Fixes #9

@Oliver2213
Copy link
Member

Thanks for this! I tested with the container you mentioned, first using overpass and then switching the backend URL. I get this error:

ERROR:server:request: /tiles/16/18745/25070.json
ERROR:server:[Errno 2] No such file or directory
ERROR:aiohttp.server:Error handling request

It seems to get to the point of opening the connection in query, but then throws that exception.

@steinbro
Copy link
Member Author

That's weird; I didn't change anything that involves writing or reading to files. I'm not able to reproduce this. Maybe this is also Sentry related -- try commenting out the @sentry_sdk.trace decorator in postgis.py? Also, are you running through a Docker container or just a virtualenv?

@Oliver2213
Copy link
Member

I'm running it in a docker container. I pulled out all the sentry stuff just to be sure for testing - when I do, I still get the same error. No file name given either. So as far as I can tell it isn't Sentry, and it doesn't seem to be the overpass stuff, since that worked in my tests.

@Oliver2213
Copy link
Member

I did track it down to right as it goes to get a connection and a cursor with print statements. I read the diff before testing - yeah, no changes I saw related to files. :(

@steinbro
Copy link
Member Author

Hmm, this might be a bug with aiopg (which the Overpass backend doesn't use): aio-libs/aiopg#837

Seems it might be specific to a particular combination of Python and SSL versions, so you could try installing different versions, or try some of the other workarounds suggested in that thread.

@steinbro
Copy link
Member Author

OK, try again -- I managed to recreate the issue, and I pulled a monkey-patch workaround from the aiopg issue thread linked above that eliminates the error.

@Oliver2213
Copy link
Member

Hmm. I re-applied my sentry-removal changes after updating to be sure I was doing the same thing. Now I get this:

======== Running on http://0.0.0.0:8081 ========
(Press CTRL+C to quit)
Connection refused
        Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
        Is the server running on that host and accepting TCP/IP connections?

I'm not sure this isn't just me messing something up here; let me know if you can reproduce this.

@steinbro
Copy link
Member Author

Yes, I also ran into this. if you are running Overscape in a Docker container that's trying to talk to a PostGIS server on the host machine, then the backend hostname should be host.docker.internal rather than localhost.

@Oliver2213
Copy link
Member

Hmm. That's what my searching turned up too, but that also didn't seem to work.
After seeing this though and doing more looking, I saw someone mention the internal gateway IP, 172.17.0.1, which did work.
Success!

@Oliver2213
Copy link
Member

This looks good to merge if you're ready (caching, any more metrics you'd like) 🎉

@Oliver2213 Oliver2213 merged commit 3274bee into main Jul 23, 2023
@Oliver2213
Copy link
Member

❇️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support PostGIS server backend
2 participants