planet-dump-ng icon indicating copy to clipboard operation
planet-dump-ng copied to clipboard

Occasional lockups dumping planet

Open tomhughes opened this issue 3 years ago • 12 comments

We've had a couple of instances - one in July (https://github.com/openstreetmap/operations/issues/552) and one this week (https://github.com/openstreetmap/operations/issues/568) where planetdump-ng has experienced some sort of thread deadlock and stopped making progress.

I grabbed a full backtrace of all threads this time (https://gist.github.com/tomhughes/250e1504f4689fc31a0ca4e0ab4e029e) and from analysing the output it looks like it had completed nodes and ways and was in the middle of the relations when it stopped.

tomhughes avatar Sep 26 '21 11:09 tomhughes

We had one good run but it looks like last week locked up again :-(

tomhughes avatar Oct 11 '21 09:10 tomhughes

Weird that this is happening so often now. :thinking: I wonder if something changed?

Thanks very much for the thread backtraces, they were very helpful. It looks like one of the output writer threads has died at some point while outputting the relations and this isn't handled properly.

It looks like the incron script that runs planet-dump-ng should send me any output, but the last time it sent me anything was July 2020... So either the output isn't being written to disk, or the script isn't mailing it. If it happens again, please look if there's a /tmp/planetdump.log.XXX file. If it's non-empty, then it might give a better clue what's happening.

zerebubuth avatar Oct 11 '21 11:10 zerebubuth

Unfortunately the wrapper script deletes the log after it has mailed it so it's no longer there.

I assume it must have been empty though, or it should have been emailed to you as you say and I see no signs of that.

tomhughes avatar Oct 11 '21 11:10 tomhughes

Yeah, I thought the same, but the log file should never be empty. Until July 2020, I was getting weekly confirms of the form:

Writing changesets... Writing nodes... Writing ways... Writing relations... Done

real 3530m46.156s user 31670m53.427s sys 972m26.327s

But then I got a few errors around the 14-16th July, and nothing since. (Clearly I wasn't doing an awesome job noticing these emails, or I'd have realised they'd stopped coming before now.)

I think I made a change that could help (assuming this is how the thread exits...). Please could you try version 1.2.2 and see if that helps? https://github.com/zerebubuth/planet-dump-ng/releases/tag/v1.2.2

zerebubuth avatar Oct 11 '21 16:10 zerebubuth

I've deployed that, and I think I've figured out the email problem and fixed it. I think you've broken something though because I get a stream of errors now if I try and start the dump:

pg_restore: error: one of -d/--dbname and -f/--file must be specified

I assume this is something to do with e2d9c704098a85e29d2e0e8a5615617a45a26594?

tomhughes avatar Oct 11 '21 19:10 tomhughes

Ooops, fail. Looks like the machine I was testing on had a truly ancient version PostgreSQL (9!). I reverted that commit and pushed a new version, v.1.2.3.

https://github.com/zerebubuth/planet-dump-ng/releases/tag/v1.2.3

zerebubuth avatar Oct 11 '21 20:10 zerebubuth

I ran a quick test to validate that a simulated runtime_error in pbf_writer::relations is handled ok now:

10000 = very first relation id in dump:

    if (r.id == 10000) { BOOST_THROW_EXCEPTION(std::runtime_error("bla")); }

Result on 3e482634c7959f27200f4c6433ae89aefe7fd2aa:

Writing changesets...
Writing nodes...
Writing ways...
Writing relations...
EXCEPTION: writer_thread(1): pbf_writer.cpp(613): Throw in function virtual void pbf_writer::relations(const std::vector<relation>&, const std::vector<relation_member>&, const std::vector<old_tag>&)
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> >
std::exception::what: bla

<stuck>

Result on b1903036d7fb51c70a1746466518281319f93ac8:

Finishing thread with 24 bytes
Writing changesets...
Writing nodes...
Writing ways...
Writing relations...
EXCEPTION: writer_thread(1): pbf_writer.cpp(613): Throw in function virtual void pbf_writer::relations(const std::vector<relation>&, const std::vector<relation_member>&, const std::vector<old_tag>&)
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> >
std::exception::what: bla
. Trying to continue...
Done

echo $? returns 0 in case of an issue. This may not be ideal for monitoring...

mmd-osm avatar Oct 11 '21 20:10 mmd-osm

I was wondering if the issue was reproducible, i.e. when processing the same db dump twice, it would show exactly the same behavior as with the previous run.

Given that this happened in relations (which tend to be much larger than ways and nodes), I could imagine that a certain combination of large relations might trigger some rare bug in the pbf writer code, e.g. due to lack of space in a pbf block.

mmd-osm avatar Oct 12 '21 07:10 mmd-osm

So, do the mails with errors arrive now at least?

It seems planet dump has failed again? Today is 2022-09-20, and last one is planet-220905.osm.pbf (created on 2022-09-10).

mnalis avatar Sep 20 '22 20:09 mnalis

Yes it failed, yes I got email, yes our alerts went off, yes we are continuing to investigate.

tomhughes avatar Sep 20 '22 20:09 tomhughes

As you can see if you look at #25 which is the actual ticket where we're currently dealing with this...

tomhughes avatar Sep 20 '22 20:09 tomhughes

Which is actually a totally separate issue - it's a crash rather than a lockup.

tomhughes avatar Sep 20 '22 20:09 tomhughes