When adding and removing zones at close to the same time, a deadlock can occur when do_addzone() tries to go exclusive after opening an LMDB transaction, and while it's waiting for other tasks to complete their processing, one of the zone tasks running rmzone() tries to open an LMDB transaction and hangs. The purpose of calling nzd_open() before going exclusive was to make sure we had permission to open the database so that we could bail out right away if we didn't, before incurring the cost of an exclusive lock and messing with the internal zone configuration. I hadn't realized that only one writer transaction could be open at the same time. We're going to have to do a quick open-and-close instead, then open a new transaction after relinquishing exclusivity.