Fix db_test under tsan
Fix db_test under tsan

Summary:
It looks like there's some locking going on here, and so if
the Cursor outlives the DB (or vice-versa), we'll either deadlock or
unlock an unlocked mutex.

Reviewed By: dzhulgakov

Differential Revision: D4224727

fbshipit-source-id: 886401a9f2824f3168fb0b2fd4df6046369e5590

xzturn/caffe2,xzturn/caffe2,davinwang/caffe2,pietern/caffe2,xzturn/caffe2,bwasti/caffe2,davinwang/caffe2,Yangqing/caffe2,sf-wind/caffe2,bwasti/caffe2,sf-wind/caffe2,davinwang/caffe2,bwasti/caffe2,Yangqing/caffe2,bwasti/caffe2,sf-wind/caffe2,xzturn/caffe2,Yangqing/caffe2,Yangqing/caffe2,sf-wind/caffe2,davinwang/caffe2,pietern/caffe2,davinwang/caffe2,caffe2/caffe2,bwasti/caffe2,Yangqing/caffe2,sf-wind/caffe2,xzturn/caffe2,pietern/caffe2,pietern/caffe2,pietern/caffe2