Update details documents in a single, atomic step
Right now, we're writing details documents in the last phase of the hourly updater, but one after the other. And when we're done, we're writing the
relays_published timestamp indicating which consensus these details documents are based on.
Nusenu points out on tor-dev@ that this may create a situation when a details response is returned that contains details documents based on a later consensus than what's contained in the
relays_published timestamp that is given in the response.
Another downside of not updating all documents at once is that the sum of network fractions is not always exactly 100%, depending on which documents have already been updated.
A possible workaround would be to include a timestamp in each details documents referencing the last known consensus at the time of writing the document. That would fix the problem pointed out by Nusenu, but not the problem with fractions. That timestamp would also be a potential source for confusion, because the details documents of non-running relays or bridges are not rewritten every hour. Also, another workaround for checking whether a details document was updated recently might be to check whether
last_seen > relays_published || (last_seen == relays_published && !running) (untested).
A possible real fix would be to store all documents in a database and update them in a single transaction.
Not sure if there are other (simple) solutions available that don't require switching to a database just yet.