Somewhat relevant is this article, https://danluu.com/file-consistency/ which was discussed here a while, back.
(I think there was at least one more article by danluu on this subject but this one I remembered by name, having discussed it several times with colleagues when considering using something (sqlite) less ad hoc for temporary data)