SQLite Forum

set/get last_insert_rowid - To mutex or not mutex?
Login
That's getting into memory-model guarantees, and platform-specific issues.  
C++ didn't have an official memory-model until C++11, and I'm not even sure  
when one was standardized for C, when SQLite requires only C89.

But I hear what you are saying. On modern HW with 64-bit atomic writes,  
the un-mutexed read should be visible thanks to the memory barrier, and  
give you a *complete* lastRowid. Maybe not the one you want, i.e. not the  
one from the table you expect (or the insert you expect), in case of MT  
access that violates the SQLite documented usage constraints.

Quite subtle overall, I'd say.