Added retry loop to threaded db ops.