fix bug where db was accessed at the same time from two threads (while saving dirty data + retriving grief at the same time) causing massive error (closes #659)