Skip to content

Commit

Permalink
Fix data race on the writing_rollback variable detected by the DRD an…
Browse files Browse the repository at this point in the history
…d the thread sanitizer.

Multiple threads are allowed to increment and decrement this variable without
any atomicity.  The solution is to change the type of the writing_rollback
variable from an 'int' to an 'atomic_int'.

One may need to run the following test cases multiple times to stumble upon
the data race.

ctest -R ydb/drd_test_groupcommit_count --verbose

4104: ==21516== Thread 43:
4104: ==21516== Conflicting load by thread 43 at 0x04c22440 size 4
4104: ==21516==    at 0x4B4EB26: rollback_log_create(tokutxn*, blocknum_s, rollback_log_node**) (rollback.cc:160)
4104: ==21516==    by 0x4B4F4D9: toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) (rollback.cc:327)
4104: ==21516==    by 0x4B6F45F: toku_logger_save_rollback_cmdinsert(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2007)
4104: ==21516==    by 0x4AF3117: ft_txn_log_insert(ft*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, ft_msg_type) (ft-ops.cc:2406)
4104: ==21516==    by 0x4AF32B0: toku_ft_maybe_insert(ft_handle*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, __toku_lsn, bool, ft_msg_type) (ft-ops.cc:2423)
4104: ==21516==    by 0x4AA2AA9: db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, int, bool) (ydb_write.cc:221)
4104: ==21516==    by 0x4AA2CB3: toku_db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, unsigned int, bool) (ydb_write.cc:248)
4104: ==21516==    by 0x4AA68FC: autotxn_db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, unsigned int) (ydb_write.cc:1078)
4104: ==21516==    by 0x10B099: start_a_thread(void*) (test_groupcommit_count.cc:64)
4104: ==21516==    by 0x48414BA: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4104: ==21516==    by 0x4C5D668: start_thread (pthread_create.c:479)
4104: ==21516==    by 0x4D99322: clone (clone.S:95)
4104: ==21516== Allocation context: BSS section of /home/rfp/projects/tokuft-Debug-gcc-7/src/libtokufractaltree.so
4104: ==21516== Other segment start (thread 42)
4104: ==21516==    at 0x484587C: pthread_mutex_unlock (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4104: ==21516==    by 0x4B8BE37: pc_unlock() (partitioned_counter.cc:151)
4104: ==21516==    by 0x4B8C583: get_or_alloc_thread_local_counter(partitioned_counter*) (partitioned_counter.cc:366)
4104: ==21516==    by 0x4B8C5C0: increment_partitioned_counter (partitioned_counter.cc:375)
4104: ==21516==    by 0x4ACD9B5: evictor::add_pair_attr(pair_attr_s) (cachetable.cc:3769)
4104: ==21516==    by 0x4AC684E: cachetable_insert_pair_at(cachetable*, ctpair*, pair_attr_s) (cachetable.cc:871)
4104: ==21516==    by 0x4AC689E: cachetable_put_internal(cachefile*, ctpair*, void*, pair_attr_s, void (*)(blocknum_s, void*, ctpair*)) (cachetable.cc:897)
4104: ==21516==    by 0x4AC7410: toku_cachetable_put(cachefile*, blocknum_s, unsigned int, void*, pair_attr_s, CACHETABLE_WRITE_CALLBACK, void (*)(blocknum_s, void*, ctpair*)) (cachetable.cc:1207)
4104: ==21516==    by 0x4B4EC6F: rollback_log_create(tokutxn*, blocknum_s, rollback_log_node**) (rollback.cc:170)
4104: ==21516==    by 0x4B4F4D9: toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) (rollback.cc:327)
4104: ==21516==    by 0x4B6F45F: toku_logger_save_rollback_cmdinsert(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2007)
4104: ==21516==    by 0x4AF3117: ft_txn_log_insert(ft*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, ft_msg_type) (ft-ops.cc:2406)
4104: ==21516== Other segment end (thread 42)
4104: ==21516==    at 0x484482C: pthread_mutex_lock (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4104: ==21516==    by 0x4A90590: toku_mutex_lock_with_source_location(toku_mutex_t*, char const*, int) (toku_pthread.h:267)
4104: ==21516==    by 0x4AC49BB: pair_lock(ctpair*) (cachetable.cc:117)
4104: ==21516==    by 0x4AC8D38: cachetable_unpin_internal(cachefile*, ctpair*, cachetable_dirty, pair_attr_s, bool) (cachetable.cc:1899)
4104: ==21516==    by 0x4AC8F5B: toku_cachetable_unpin(cachefile*, ctpair*, cachetable_dirty, pair_attr_s) (cachetable.cc:1932)
4104: ==21516==    by 0x4B4ED32: toku_rollback_log_unpin(tokutxn*, rollback_log_node*) (rollback.cc:181)
4104: ==21516==    by 0x4B6F5CE: toku_logger_save_rollback_cmdinsert(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2029)
4104: ==21516==    by 0x4AF3117: ft_txn_log_insert(ft*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, ft_msg_type) (ft-ops.cc:2406)
4104: ==21516==    by 0x4AF32B0: toku_ft_maybe_insert(ft_handle*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, __toku_lsn, bool, ft_msg_type) (ft-ops.cc:2423)
4104: ==21516==    by 0x4AA2AA9: db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, int, bool) (ydb_write.cc:221)
4104: ==21516==    by 0x4AA2CB3: toku_db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, unsigned int, bool) (ydb_write.cc:248)
4104: ==21516==    by 0x4AA68FC: autotxn_db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, unsigned int) (ydb_write.cc:1078)
4104: ==21516==
4104: ==21516== Conflicting store by thread 43 at 0x04c22440 size 4
4104: ==21516==    at 0x4B4EB32: rollback_log_create(tokutxn*, blocknum_s, rollback_log_node**) (rollback.cc:160)
4104: ==21516==    by 0x4B4F4D9: toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) (rollback.cc:327)
4104: ==21516==    by 0x4B6F45F: toku_logger_save_rollback_cmdinsert(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2007)
4104: ==21516==    by 0x4AF3117: ft_txn_log_insert(ft*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, ft_msg_type) (ft-ops.cc:2406)
4104: ==21516==    by 0x4AF32B0: toku_ft_maybe_insert(ft_handle*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, __toku_lsn, bool, ft_msg_type) (ft-ops.cc:2423)
4104: ==21516==    by 0x4AA2AA9: db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, int, bool) (ydb_write.cc:221)
4104: ==21516==    by 0x4AA2CB3: toku_db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, unsigned int, bool) (ydb_write.cc:248)
4104: ==21516==    by 0x4AA68FC: autotxn_db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, unsigned int) (ydb_write.cc:1078)
4104: ==21516==    by 0x10B099: start_a_thread(void*) (test_groupcommit_count.cc:64)
4104: ==21516==    by 0x48414BA: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4104: ==21516==    by 0x4C5D668: start_thread (pthread_create.c:479)
4104: ==21516==    by 0x4D99322: clone (clone.S:95)
4104: ==21516== Allocation context: BSS section of /home/rfp/projects/tokuft-Debug-gcc-7/src/libtokufractaltree.so
4104: ==21516== Other segment start (thread 42)
4104: ==21516==    at 0x484587C: pthread_mutex_unlock (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4104: ==21516==    by 0x4B8BE37: pc_unlock() (partitioned_counter.cc:151)
4104: ==21516==    by 0x4B8C583: get_or_alloc_thread_local_counter(partitioned_counter*) (partitioned_counter.cc:366)
4104: ==21516==    by 0x4B8C5C0: increment_partitioned_counter (partitioned_counter.cc:375)
4104: ==21516==    by 0x4ACD9B5: evictor::add_pair_attr(pair_attr_s) (cachetable.cc:3769)
4104: ==21516==    by 0x4AC684E: cachetable_insert_pair_at(cachetable*, ctpair*, pair_attr_s) (cachetable.cc:871)
4104: ==21516==    by 0x4AC689E: cachetable_put_internal(cachefile*, ctpair*, void*, pair_attr_s, void (*)(blocknum_s, void*, ctpair*)) (cachetable.cc:897)
4104: ==21516==    by 0x4AC7410: toku_cachetable_put(cachefile*, blocknum_s, unsigned int, void*, pair_attr_s, CACHETABLE_WRITE_CALLBACK, void (*)(blocknum_s, void*, ctpair*)) (cachetable.cc:1207)
4104: ==21516==    by 0x4B4EC6F: rollback_log_create(tokutxn*, blocknum_s, rollback_log_node**) (rollback.cc:170)
4104: ==21516==    by 0x4B4F4D9: toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) (rollback.cc:327)
4104: ==21516==    by 0x4B6F45F: toku_logger_save_rollback_cmdinsert(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2007)
4104: ==21516==    by 0x4AF3117: ft_txn_log_insert(ft*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, ft_msg_type) (ft-ops.cc:2406)
4104: ==21516== Other segment end (thread 42)
4104: ==21516==    at 0x484482C: pthread_mutex_lock (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4104: ==21516==    by 0x4A90590: toku_mutex_lock_with_source_location(toku_mutex_t*, char const*, int) (toku_pthread.h:267)
4104: ==21516==    by 0x4AC49BB: pair_lock(ctpair*) (cachetable.cc:117)
4104: ==21516==    by 0x4AC8D38: cachetable_unpin_internal(cachefile*, ctpair*, cachetable_dirty, pair_attr_s, bool) (cachetable.cc:1899)
4104: ==21516==    by 0x4AC8F5B: toku_cachetable_unpin(cachefile*, ctpair*, cachetable_dirty, pair_attr_s) (cachetable.cc:1932)
4104: ==21516==    by 0x4B4ED32: toku_rollback_log_unpin(tokutxn*, rollback_log_node*) (rollback.cc:181)
4104: ==21516==    by 0x4B6F5CE: toku_logger_save_rollback_cmdinsert(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2029)
4104: ==21516==    by 0x4AF3117: ft_txn_log_insert(ft*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, ft_msg_type) (ft-ops.cc:2406)
4104: ==21516==    by 0x4AF32B0: toku_ft_maybe_insert(ft_handle*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, __toku_lsn, bool, ft_msg_type) (ft-ops.cc:2423)
4104: ==21516==    by 0x4AA2AA9: db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, int, bool) (ydb_write.cc:221)
4104: ==21516==    by 0x4AA2CB3: toku_db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, unsigned int, bool) (ydb_write.cc:248)
4104: ==21516==    by 0x4AA68FC: autotxn_db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, unsigned int) (ydb_write.cc:1078)

ctest -R ydb/drd_tiny_test_stress0 --verbose

4107: ==21390== Thread 52:
4107: ==21390== Conflicting load by thread 52 at 0x04c22440 size 4
4107: ==21390==    at 0x4B4EB26: rollback_log_create(tokutxn*, blocknum_s, rollback_log_node**) (rollback.cc:160)
4107: ==21390==    by 0x4B4F4D9: toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) (rollback.cc:327)
4107: ==21390==    by 0x4B6FF22: toku_logger_save_rollback_cmdupdate(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2168)
4107: ==21390==    by 0x4AF3741: toku_ft_maybe_update(ft_handle*, __toku_dbt const*, __toku_dbt const*, tokutxn*, bool, __toku_lsn, bool) (ft-ops.cc:2485)
4107: ==21390==    by 0x4AA2FB8: toku_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:290)
4107: ==21390==    by 0x4AA69C5: autotxn_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:1094)
4107: ==21390==    by 0x113C8F: update_op_db(__toku_db*, __toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1488)
4107: ==21390==    by 0x113D55: update_op(__toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1508)
4107: ==21390==    by 0x10F64D: worker(void*) (threaded_stress_test_helpers.h:537)
4107: ==21390==    by 0x48414BA: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4107: ==21390==    by 0x4C8B668: start_thread (pthread_create.c:479)
4107: ==21390==    by 0x4DC7322: clone (clone.S:95)
4107: ==21390== Allocation context: BSS section of /home/rfp/projects/tokuft-Debug-gcc-7/src/libtokufractaltree.so
4107: ==21390== Other segment start (thread 53)
4107: ==21390==    at 0x484E3FB: pthread_rwlock_unlock (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4107: ==21390==    by 0x4A9095C: toku_pthread_rwlock_wrunlock(toku_pthread_rwlock_t*) (toku_pthread.h:496)
4107: ==21390==    by 0x4ACCE5D: pair_list::write_list_unlock() (cachetable.cc:3580)
4107: ==21390==    by 0x4AC742C: toku_cachetable_put(cachefile*, blocknum_s, unsigned int, void*, pair_attr_s, CACHETABLE_WRITE_CALLBACK, void (*)(blocknum_s, void*, ctpair*)) (cachetable.cc:1215)
4107: ==21390==    by 0x4B4EC6F: rollback_log_create(tokutxn*, blocknum_s, rollback_log_node**) (rollback.cc:170)
4107: ==21390==    by 0x4B4F4D9: toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) (rollback.cc:327)
4107: ==21390==    by 0x4B6FF22: toku_logger_save_rollback_cmdupdate(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2168)
4107: ==21390==    by 0x4AF3741: toku_ft_maybe_update(ft_handle*, __toku_dbt const*, __toku_dbt const*, tokutxn*, bool, __toku_lsn, bool) (ft-ops.cc:2485)
4107: ==21390==    by 0x4AA2FB8: toku_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:290)
4107: ==21390==    by 0x4AA69C5: autotxn_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:1094)
4107: ==21390==    by 0x113C8F: update_op_db(__toku_db*, __toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1488)
4107: ==21390==    by 0x113D55: update_op(__toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1508)
4107: ==21390== Other segment end (thread 53)
4107: ==21390==    at 0x484482C: pthread_mutex_lock (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4107: ==21390==    by 0x4A90590: toku_mutex_lock_with_source_location(toku_mutex_t*, char const*, int) (toku_pthread.h:267)
4107: ==21390==    by 0x4AC49BB: pair_lock(ctpair*) (cachetable.cc:117)
4107: ==21390==    by 0x4AC8D38: cachetable_unpin_internal(cachefile*, ctpair*, cachetable_dirty, pair_attr_s, bool) (cachetable.cc:1899)
4107: ==21390==    by 0x4AC8F5B: toku_cachetable_unpin(cachefile*, ctpair*, cachetable_dirty, pair_attr_s) (cachetable.cc:1932)
4107: ==21390==    by 0x4B4ED32: toku_rollback_log_unpin(tokutxn*, rollback_log_node*) (rollback.cc:181)
4107: ==21390==    by 0x4B70091: toku_logger_save_rollback_cmdupdate(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2190)
4107: ==21390==    by 0x4AF3741: toku_ft_maybe_update(ft_handle*, __toku_dbt const*, __toku_dbt const*, tokutxn*, bool, __toku_lsn, bool) (ft-ops.cc:2485)
4107: ==21390==    by 0x4AA2FB8: toku_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:290)
4107: ==21390==    by 0x4AA69C5: autotxn_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:1094)
4107: ==21390==    by 0x113C8F: update_op_db(__toku_db*, __toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1488)
4107: ==21390==    by 0x113D55: update_op(__toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1508)
4107: ==21390== Other segment start (thread 53)
4107: ==21390==    at 0x484587C: pthread_mutex_unlock (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4107: ==21390==    by 0x4A90508: toku_mutex_unlock(toku_mutex_t*) (toku_pthread.h:256)
4107: ==21390==    by 0x4B521CD: rollback_log_node_cache::get_rollback_log_node(tokutxn*, rollback_log_node**) (rollback_log_node_cache.cc:101)
4107: ==21390==    by 0x4B4F478: toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) (rollback.cc:316)
4107: ==21390==    by 0x4B6FF22: toku_logger_save_rollback_cmdupdate(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2168)
4107: ==21390==    by 0x4AF3741: toku_ft_maybe_update(ft_handle*, __toku_dbt const*, __toku_dbt const*, tokutxn*, bool, __toku_lsn, bool) (ft-ops.cc:2485)
4107: ==21390==    by 0x4AA2FB8: toku_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:290)
4107: ==21390==    by 0x4AA69C5: autotxn_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:1094)
4107: ==21390==    by 0x113C8F: update_op_db(__toku_db*, __toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1488)
4107: ==21390==    by 0x113D55: update_op(__toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1508)
4107: ==21390==    by 0x10F64D: worker(void*) (threaded_stress_test_helpers.h:537)
4107: ==21390==    by 0x48414BA: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4107: ==21390== Other segment end (thread 53)
4107: ==21390==    at 0x484482C: pthread_mutex_lock (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4107: ==21390==    by 0x4A90590: toku_mutex_lock_with_source_location(toku_mutex_t*, char const*, int) (toku_pthread.h:267)
4107: ==21390==    by 0x4B3A2D1: block_table::_mutex_lock() (block_table.cc:72)
4107: ==21390==    by 0x4B3BE7D: block_table::allocate_blocknum(blocknum_s*, ft*) (block_table.cc:682)
4107: ==21390==    by 0x4B4EBBB: rollback_log_create(tokutxn*, blocknum_s, rollback_log_node**) (rollback.cc:167)
4107: ==21390==    by 0x4B4F4D9: toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) (rollback.cc:327)
4107: ==21390==    by 0x4B6FF22: toku_logger_save_rollback_cmdupdate(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2168)
4107: ==21390==    by 0x4AF3741: toku_ft_maybe_update(ft_handle*, __toku_dbt const*, __toku_dbt const*, tokutxn*, bool, __toku_lsn, bool) (ft-ops.cc:2485)
4107: ==21390==    by 0x4AA2FB8: toku_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:290)
4107: ==21390==    by 0x4AA69C5: autotxn_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:1094)
4107: ==21390==    by 0x113C8F: update_op_db(__toku_db*, __toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1488)
4107: ==21390==    by 0x113D55: update_op(__toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1508)
4107: ==21390==
4107: ==21390== Conflicting store by thread 52 at 0x04c22440 size 4
4107: ==21390==    at 0x4B4EB32: rollback_log_create(tokutxn*, blocknum_s, rollback_log_node**) (rollback.cc:160)
4107: ==21390==    by 0x4B4F4D9: toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) (rollback.cc:327)
4107: ==21390==    by 0x4B6FF22: toku_logger_save_rollback_cmdupdate(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2168)
4107: ==21390==    by 0x4AF3741: toku_ft_maybe_update(ft_handle*, __toku_dbt const*, __toku_dbt const*, tokutxn*, bool, __toku_lsn, bool) (ft-ops.cc:2485)
4107: ==21390==    by 0x4AA2FB8: toku_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:290)
4107: ==21390==    by 0x4AA69C5: autotxn_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:1094)
4107: ==21390==    by 0x113C8F: update_op_db(__toku_db*, __toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1488)
4107: ==21390==    by 0x113D55: update_op(__toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1508)
4107: ==21390==    by 0x10F64D: worker(void*) (threaded_stress_test_helpers.h:537)
4107: ==21390==    by 0x48414BA: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4107: ==21390==    by 0x4C8B668: start_thread (pthread_create.c:479)
4107: ==21390==    by 0x4DC7322: clone (clone.S:95)
4107: ==21390== Allocation context: BSS section of /home/rfp/projects/tokuft-Debug-gcc-7/src/libtokufractaltree.so
4107: ==21390== Other segment start (thread 53)
4107: ==21390==    at 0x484E3FB: pthread_rwlock_unlock (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4107: ==21390==    by 0x4A9095C: toku_pthread_rwlock_wrunlock(toku_pthread_rwlock_t*) (toku_pthread.h:496)
4107: ==21390==    by 0x4ACCE5D: pair_list::write_list_unlock() (cachetable.cc:3580)
4107: ==21390==    by 0x4AC742C: toku_cachetable_put(cachefile*, blocknum_s, unsigned int, void*, pair_attr_s, CACHETABLE_WRITE_CALLBACK, void (*)(blocknum_s, void*, ctpair*)) (cachetable.cc:1215)
4107: ==21390==    by 0x4B4EC6F: rollback_log_create(tokutxn*, blocknum_s, rollback_log_node**) (rollback.cc:170)
4107: ==21390==    by 0x4B4F4D9: toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) (rollback.cc:327)
4107: ==21390==    by 0x4B6FF22: toku_logger_save_rollback_cmdupdate(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2168)
4107: ==21390==    by 0x4AF3741: toku_ft_maybe_update(ft_handle*, __toku_dbt const*, __toku_dbt const*, tokutxn*, bool, __toku_lsn, bool) (ft-ops.cc:2485)
4107: ==21390==    by 0x4AA2FB8: toku_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:290)
4107: ==21390==    by 0x4AA69C5: autotxn_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:1094)
4107: ==21390==    by 0x113C8F: update_op_db(__toku_db*, __toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1488)
4107: ==21390==    by 0x113D55: update_op(__toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1508)
4107: ==21390== Other segment end (thread 53)
4107: ==21390==    at 0x484482C: pthread_mutex_lock (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4107: ==21390==    by 0x4A90590: toku_mutex_lock_with_source_location(toku_mutex_t*, char const*, int) (toku_pthread.h:267)
4107: ==21390==    by 0x4AC49BB: pair_lock(ctpair*) (cachetable.cc:117)
4107: ==21390==    by 0x4AC8D38: cachetable_unpin_internal(cachefile*, ctpair*, cachetable_dirty, pair_attr_s, bool) (cachetable.cc:1899)
4107: ==21390==    by 0x4AC8F5B: toku_cachetable_unpin(cachefile*, ctpair*, cachetable_dirty, pair_attr_s) (cachetable.cc:1932)
4107: ==21390==    by 0x4B4ED32: toku_rollback_log_unpin(tokutxn*, rollback_log_node*) (rollback.cc:181)
4107: ==21390==    by 0x4B70091: toku_logger_save_rollback_cmdupdate(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2190)
4107: ==21390==    by 0x4AF3741: toku_ft_maybe_update(ft_handle*, __toku_dbt const*, __toku_dbt const*, tokutxn*, bool, __toku_lsn, bool) (ft-ops.cc:2485)
4107: ==21390==    by 0x4AA2FB8: toku_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:290)
4107: ==21390==    by 0x4AA69C5: autotxn_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:1094)
4107: ==21390==    by 0x113C8F: update_op_db(__toku_db*, __toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1488)
4107: ==21390==    by 0x113D55: update_op(__toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1508)
4107: ==21390== Other segment start (thread 53)
4107: ==21390==    at 0x484587C: pthread_mutex_unlock (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4107: ==21390==    by 0x4A90508: toku_mutex_unlock(toku_mutex_t*) (toku_pthread.h:256)
4107: ==21390==    by 0x4B521CD: rollback_log_node_cache::get_rollback_log_node(tokutxn*, rollback_log_node**) (rollback_log_node_cache.cc:101)
4107: ==21390==    by 0x4B4F478: toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) (rollback.cc:316)
4107: ==21390==    by 0x4B6FF22: toku_logger_save_rollback_cmdupdate(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2168)
4107: ==21390==    by 0x4AF3741: toku_ft_maybe_update(ft_handle*, __toku_dbt const*, __toku_dbt const*, tokutxn*, bool, __toku_lsn, bool) (ft-ops.cc:2485)
4107: ==21390==    by 0x4AA2FB8: toku_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:290)
4107: ==21390==    by 0x4AA69C5: autotxn_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:1094)
4107: ==21390==    by 0x113C8F: update_op_db(__toku_db*, __toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1488)
4107: ==21390==    by 0x113D55: update_op(__toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1508)
4107: ==21390==    by 0x10F64D: worker(void*) (threaded_stress_test_helpers.h:537)
4107: ==21390==    by 0x48414BA: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4107: ==21390== Other segment end (thread 53)
4107: ==21390==    at 0x484482C: pthread_mutex_lock (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_drd-amd64-linux.so)
4107: ==21390==    by 0x4A90590: toku_mutex_lock_with_source_location(toku_mutex_t*, char const*, int) (toku_pthread.h:267)
4107: ==21390==    by 0x4B3A2D1: block_table::_mutex_lock() (block_table.cc:72)
4107: ==21390==    by 0x4B3BE7D: block_table::allocate_blocknum(blocknum_s*, ft*) (block_table.cc:682)
4107: ==21390==    by 0x4B4EBBB: rollback_log_create(tokutxn*, blocknum_s, rollback_log_node**) (rollback.cc:167)
4107: ==21390==    by 0x4B4F4D9: toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) (rollback.cc:327)
4107: ==21390==    by 0x4B6FF22: toku_logger_save_rollback_cmdupdate(tokutxn*, FILENUM, BYTESTRING*) (log_code.cc:2168)
4107: ==21390==    by 0x4AF3741: toku_ft_maybe_update(ft_handle*, __toku_dbt const*, __toku_dbt const*, tokutxn*, bool, __toku_lsn, bool) (ft-ops.cc:2485)
4107: ==21390==    by 0x4AA2FB8: toku_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:290)
4107: ==21390==    by 0x4AA69C5: autotxn_db_update(__toku_db*, __toku_db_txn*, __toku_dbt const*, __toku_dbt const*, unsigned int) (ydb_write.cc:1094)
4107: ==21390==    by 0x113C8F: update_op_db(__toku_db*, __toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1488)
4107: ==21390==    by 0x113D55: update_op(__toku_db_txn*, arg*, void*, void*) (threaded_stress_test_helpers.h:1508)

Also observed by the thread sanitizer when running
ctest -R ydb/checkpoint_fairness --verbose

4793: WARNING: ThreadSanitizer: data race (pid=10298)
4793:   Write of size 4 at 0x7fd7194ac2b8 by thread T35 (mutexes: read M11, write M1048777):
4793:     #0 rollback_log_create(tokutxn*, blocknum_s, rollback_log_node**) /home/rfp/projects/tokuft/ft/txn/rollback.cc:160:21 (libtokufractaltree.so+0x18b990)
4793:     #1 toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) /home/rfp/projects/tokuft/ft/txn/rollback.cc:327:13 (libtokufractaltree.so+0x18b4c9)
4793:     #2 toku_logger_save_rollback_cmdinsert(tokutxn*, FILENUM, BYTESTRING*) /home/rfp/projects/tokuft-tsan/ft/log_code.cc:2007:3 (libtokufractaltree.so+0x1c7912)
4793:     #3 ft_txn_log_insert(ft*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, ft_msg_type) /home/rfp/projects/tokuft/ft/ft-ops.cc:2406:9 (libtokufractaltree.so+0xd2c2c)
4793:     #4 toku_ft_maybe_insert(ft_handle*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, __toku_lsn, bool, ft_msg_type) /home/rfp/projects/tokuft/ft/ft-ops.cc:2423:5 (libtokufractaltree.so+0xd3135)
4793:     #5 db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, int, bool) /home/rfp/projects/tokuft/src/ydb_write.cc:221:13 (libtokufractaltree.so+0x45d33)
4793:     #6 toku_db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, unsigned int, bool) /home/rfp/projects/tokuft/src/ydb_write.cc:248:13 (libtokufractaltree.so+0x456e3)
4793:     #7 autotxn_db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, unsigned int) /home/rfp/projects/tokuft/src/ydb_write.cc:1078:9 (libtokufractaltree.so+0x4ab47)
4793:     #8 start_txns(void*) /home/rfp/projects/tokuft/src/tests/checkpoint_fairness.cc:73:16 (checkpoint_fairness.tdb+0x4b6f5b)
4793:
4793:   Previous write of size 4 at 0x7fd7194ac2b8 by threa T34 (mutexes: read M11, write M1048756):
4793:     #0 rollback_log_create(tokutxn*, blocknum_s, rollback_log_node**) /home/rfp/projects/tokuft/ft/txn/rollback.cc:175:22 (libtokufractaltree.so+0x18bc94)
4793:     #1 toku_get_and_pin_rollback_log_for_new_entry(tokutxn*, rollback_log_node**) /home/rfp/projects/tokuft/ft/txn/rollback.cc:327:13 (libtokufractaltree.so+0x18b4c9)
4793:     #2 toku_logger_save_rollback_cmdinsert(tokutxn*, FILENUM, BYTESTRING*) /home/rfp/projects/tokuft-tsan/ft/log_code.cc:2007:3 (libtokufractaltree.so+0x1c7912)
4793:     #3 ft_txn_log_insert(ft*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, ft_msg_type) /home/rfp/projects/tokuft/ft/ft-ops.cc:2406:9 (libtokufractaltree.so+0xd2c2c)
4793:     #4 toku_ft_maybe_insert(ft_handle*, __toku_dbt*, __toku_dbt*, tokutxn*, bool, __toku_lsn, bool, ft_msg_type) /home/rfp/projects/tokuft/ft/ft-ops.cc:2423:5 (libtokufractaltree.so+0xd3135)
4793:     #5 db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, int, bool) /home/rfp/projects/tokuft/src/ydb_write.cc:221:13 (libtokufractaltree.so+0x45d33)
4793:     #6 toku_db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, unsigned int, bool) /home/rfp/projects/tokuft/src/ydb_write.cc:248:13 (libtokufractaltree.so+0x456e3)
4793:     #7 autotxn_db_put(__toku_db*, __toku_db_txn*, __toku_dbt*, __toku_dbt*, unsigned int) /home/rfp/projects/tokuft/src/ydb_write.cc:1078:9 (libtokufractaltree.so+0x4ab47)
4793:     #8 start_txns(void*) /home/rfp/projects/tokuft/src/tests/checkpoint_fairness.cc:73:16 (checkpoint_fairness.tdb+0x4b6f5b)
4793:
4793:   Location is global 'writing_rollback' of size 4 at 0x7fd7194ac2b8 (libtokufractaltree.so+0x0000002972b8)
  • Loading branch information
prohaska7 committed Apr 19, 2020
1 parent 17f40f8 commit 95515e8
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ft/ft-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ extern "C" {
extern uint force_recovery;
}

extern int writing_rollback;
extern std::atomic_int writing_rollback;

// The ft_header is not managed by the cachetable. Instead, it hangs off the cachefile as userdata.
struct ft_header {
Expand Down
2 changes: 1 addition & 1 deletion ft/logger/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.

#include "util/status.h"

int writing_rollback = 0;
std::atomic_int writing_rollback = {0};
extern "C" {
uint force_recovery = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion ft/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class ftnode_pivot_keys {
size_t _total_size;
};

extern int writing_rollback;
extern std::atomic_int writing_rollback;

extern "C" {
extern uint force_recovery;
Expand Down
2 changes: 1 addition & 1 deletion ft/txn/rollback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "ft/logger/log-internal.h"
#include "ft/txn/rollback-ct-callbacks.h"

extern int writing_rollback;
extern std::atomic_int writing_rollback;

static void rollback_unpin_remove_callback(CACHEKEY* cachekey, bool for_checkpoint, void* extra) {
FT CAST_FROM_VOIDP(ft, extra);
Expand Down
1 change: 1 addition & 0 deletions portability/toku_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <atomic>

__attribute__((const, always_inline))
static inline intptr_t which_cache_line(intptr_t addr) {
Expand Down
5 changes: 2 additions & 3 deletions src/ydb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
extern const char *toku_patent_string;
const char *toku_copyright_string = "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.";


extern int writing_rollback;

#include <db.h>
#include <errno.h>
#include <string.h>
Expand Down Expand Up @@ -90,6 +87,8 @@ extern int writing_rollback;
int toku_close_trace_file (void) { return 0; }
#endif

extern std::atomic_int writing_rollback;

extern uint force_recovery;

// Set when env is panicked, never cleared.
Expand Down

0 comments on commit 95515e8

Please sign in to comment.