std::multimap::find() is not guaranteed by the C++ standard to return the
first element of a range with equivalent keys, which may fail to retrieve
the head operation in pg.write_queue.
Switch to lower_bound() to reliably locate the head of the queue in O(log N)
time, and add an explicit check for it->first == oid to prevent falsely
matching a subsequent larger key when the target oid is missing.