Handle kv.sqlite database contention/incomplete transactions (#2790)