-
Notifications
You must be signed in to change notification settings - Fork 11
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
Strip backslash from OSM names (and fix provisioning and change analysis parameters) #947
Conversation
Fixes a few errors that have showed up in the container provisioning due to everything being pretty old. Specifically: - Debian 'stretch' is out of support. - I changed the tilegarden container to use buster, because it's already on a version of Node for which there's a 'buster' base image - The AngularJS container wouldn't build with the newer Node versions I tried, so I left it on 'stretch' and updated the apt sources list to "archive", where the packages live now. - The Bower registry is using an SSL cert based on a root certificate that 'stretch' doesn't have. I briefly tried updating the certs, but settled on just setting Bower to "strict-ssl: false"
This is something that we started doing on more recent projects and it's nice to have, since uploading the modified tfvars file is something we need to do frequently and composing the command by hand is kind of annoying.
We've been running this job with 8 vCPUs but only 31 GiB of RAM, which doesn't make a ton of sense because that's all the CPU but only half the RAM of an i3.2xlarge instance. To be fair, we didn't think we would actually get close to filling up even the 31 GiB, but apparently we are on the largest jobs, so it's time to allocate the rest. I also: - Increased the parameters we apply to the PostgreSQL instance within the analysis container, to make more use of the copious resources we're providing to these tasks. Some of the values are probably overkill, but there's no reason not to use the resources, and some could make the jobs faster or more robust. - Matched all the parameters in the staging job definiton to the ones in production. We seldom run staging jobs, so making them smaller doesn't appreciably help with keeping costs down, and it seems valuable to make the test environment as similar to production as we practically can.
Sets the size of /dev/shm (a shared-memory RAM drive built into Linux) to 4GB via the Batch task definition. Apparently Postgres uses it for some tasks (like VACUUM ANALYZE) and has been running into space constraints (that's what the "ERROR: could not resize shared memory segment" errors are about).
It turns out osm2pgrouting *really* doesn't like it if you have a backslash in a segment name. It produces an error that knocks out not just the segment in question, but everything that the tool would have otherwise loaded in the chunk that it's processing. Here's a Stack Overflow about it: https://gis.stackexchange.com/a/12873 but the recommendation there is to modify the osm2pgrouting code. I just added a command to the import_osm.sh script to use 'sed' to strip out any backslash characters.
@@ -39,7 +39,7 @@ ALTER SYSTEM SET maintenance_work_mem TO '${PFB_MAINTENANCE_WORK_MEM}'; | |||
ALTER SYSTEM SET max_wal_size TO '${PFB_MAX_WAL_SIZE}'; | |||
ALTER SYSTEM SET shared_buffers TO '${PFB_SHARED_BUFFERS}'; | |||
ALTER SYSTEM SET synchronous_commit TO ${PFB_SYNCHRONOUS_COMMIT}; | |||
ALTER SYSTEM SET temp_file_limit TO ${PFB_TEMP_FILE_LIMIT}; | |||
ALTER SYSTEM SET temp_file_limit TO '${PFB_TEMP_FILE_LIMIT}'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This had been a (large) numerical value, but changing it to "100GB" made it start breaking without quotes.
@@ -1 +1 @@ | |||
boto3==1.4.4 | |||
boto3==1.26.132 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the requirements file for the little script that updates the batch task definition. Long-term we want to get rid of it and handle the task definition in Terraform, but for now we're still using it. This upgrade was necessary because the very-old version of boto3 didn't know about the linuxParameters
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything seems to be working great! I wasn't able to actually view the details for the job due to an apparent CORS error, but the job did run successfully (once I got my VM resuscitated).
}, { | ||
"name": "PFB_WORK_MEM", | ||
"value": "3072MB" | ||
"value": "3GB" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it's the same as it was, just in GB rather than MB -- was that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was going to raise that one,too, but it's the one that gets allocated for every thread in parallel processes so it can actually balloon pretty fast. So I left it, but still changed the format to match the others.
Overview
The most important part of this PR is the smallest—a pair of lines in
import_osm.sh
that clears any backslash characters from theconverted.osm
file before we feed it toosm2pgrouting
to import into the database. It turns outosm2pgrouting
really doesn't like backslash characters. The error looks like this:That certainly looks like an error, but I had assumed it would only affect the actual segments with bad names. But it turns out where it says "Vertices inserted: 0 Split ways inserted 0" after the errors, that's an indication that it lost a lot more than the affected segments. Apparently it processes the input in chunks, and whatever other segments happen to be in the same chunk as the bad segments just get dropped on the floor.
I don't believe there's any functional purpose for which we would want backslashes in our OSM input. They're not used for encoding (the file is in UTF-8) and we don't actually use segment names for anything in the analysis anyway. So I just did a simple
sed 's/\\/backslash/'
to make them go away.Other items:
Demo
I found the location of one of the segments named
"\"
and made a tiny boundary centered on it. Here's are the before-and-after shots showing the affect of losing chunks from the OSM import:Before:
After:
Notes
The GitHub Actions deployment to staging isn't working (see #937), but I pushed this branch to staging manually.
Testing Instructions
I don't think it seems necessary to spin up a Batch worker on staging and do more runs there, but it probably makes sense to test this locally to the point of running a small analysis.
Checklist
Resolves #946