MB-19329: Addressing data races seen during bcache shutdown
MB-19329: Addressing data races seen during bcache shutdown

[1] WARNING: ThreadSanitizer: data race (pid=16606)
  Write of size 8 at 0x7d100020c0a8 by thread T2 (mutexes: write M10, write M15):
    #0 list_remove /home/abhinav/couchbaseTS/forestdb/src/list.cc:89 (fdb_functional_test+0x000000624716)
    #1 bcache_shutdown /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:1605 (fdb_functional_test+0x00000050dc8f)
    #2 filemgr_shutdown /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1758 (fdb_functional_test+0x0000005769ff)
    #3 fdb_shutdown /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7851 (fdb_functional_test+0x0000005c69a0)
    #4 multi_thread_client_shutdown(void*) /home/abhinav/couchbaseTS/forestdb/tests/functional/fdb_functional_test.cc:2011 (fdb_functional_test+0x0000004d81f1)

  Previous write of size 8 at 0x7d100020c0a8 by thread T1 (mutexes: write M23078079052191248, write M17):
    #0 list_push_front /home/abhinav/couchbaseTS/forestdb/src/list.cc:34 (fdb_functional_test+0x000000623dfe)
    #1 _bcache_release_freeblock(bcache_item*) /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:315 (fdb_functional_test+0x000000505972)
    #2 bcache_remove_clean_blocks /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:1324 (fdb_functional_test+0x00000050b627)
    #3 filemgr_free_func /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1614 (fdb_functional_test+0x00000056ad37)
    #4 filemgr_close /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1567 (fdb_functional_test+0x00000057568b)
    #5 _fdb_close /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7299 (fdb_functional_test+0x0000005a309a)
    #6 _fdb_close_root /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7270 (fdb_functional_test+0x0000005a197c)
    #7 fdb_close /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7228 (fdb_functional_test+0x0000005c2d2f)
    #8 multi_thread_client_shutdown(void*) /home/abhinav/couchbaseTS/forestdb/tests/functional/fdb_functional_test.cc:2008 (fdb_functional_test+0x0000004d8132)

[2] WARNING: ThreadSanitizer: data race (pid=3464)
  Write of size 8 at 0x7db000000000 by thread T2 (mutexes: write M10, write M15):
    #0 free <null> (fdb_functional_test+0x000000456f1b)
    #1 bcache_shutdown /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:1620 (fdb_functional_test+0x0000004de9d6)
    #2 filemgr_shutdown /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1758 (fdb_functional_test+0x0000004f989b)
    #3 fdb_shutdown /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7851 (fdb_functional_test+0x0000005152af)
    #4 multi_thread_client_shutdown(void*) /home/abhinav/couchbaseTS/forestdb/tests/functional/fdb_functional_test.cc:2011 (fdb_functional_test+0x0000004c87be)

  Previous write of size 8 at 0x7db000000000 by thread T1 (mutexes: write M18):
    #0 _fname_try_free(fnamedic_item*) /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:852 (fdb_functional_test+0x0000004ddccb)
    #1 filemgr_free_func /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1615 (fdb_functional_test+0x0000004f676f)
    #2 filemgr_close /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1567 (fdb_functional_test+0x0000004f927b)
    #3 _fdb_close /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7299 (fdb_functional_test+0x000000506bcb)
    #4 _fdb_close_root /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7270 (fdb_functional_test+0x000000506070)
    #5 fdb_close /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7228 (fdb_functional_test+0x000000513a5a)
    #6 multi_thread_client_shutdown(void*) /home/abhinav/couchbaseTS/forestdb/tests/functional/fdb_functional_test.cc:2008 (fdb_functional_test+0x0000004c8767)

Change-Id: Ib1bb146310bf1f07ba2e1317c66d421906b11794
Reviewed-on: http://review.couchbase.org/63242
Tested-by: buildbot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
Reviewed-by: Chiyoung Seo <fcffc23db27b19ee4ebba46695ee6b50e09216a2@couchbase.com>

wurikiji/forestdb,couchbase/forestdb,hisundar/forestdb,couchbase/forestdb,wurikiji/forestdb,hisundar/forestdb