Here is the race condition I've found: Glean currently has two `atexit` handlers: one to make sure the thread worked completes all of its tasks
Bug 1634310 Comment 1 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Here is the race condition I've found: Glean currently has two `atexit` handlers: (a) to make sure the thread worked completes all of its tasks, and (b) that (among other things) deletes the data directory if it's a `tmpdir`. atexit handlers are run sequentially on the main thread, but the ordering is based on the order in which they are registered, which is somewhat non-deterministic in Glean. If (b) runs before (a), the data directory is deleted, and then any operations that might be waiting the thread queue will fail with "Database not found". The fix is to combine the atexit handlers into one, and join on the thread queue *before* deleting the tempdir. This raised another issue in my mind that using a `tempdir` by default is probably not a good choice, and we are seeing this bug in `burnham` only because `burnham` doesn't override the data dir (as other "real" apps, such as `mozregression` have done). Changing the default to a retained directory probably makes sense, and I created bug 1634410 to track that work.