Try to improve robustness, make kerneldb additions atomic.