Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak of pfs keys #444

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

prohaska7
Copy link
Contributor

Valgrind finds memory leaks of pfs keys for some ydb tests. These tests create an environment, manipulate it, and close it. These tests do not open the environment. The bug is that the flag that controls the toku_ydb_destroy function is only set true if the environment is opened. The flag should be set in the toku_ydb_init function.

Reproduce:
ctest -R ydb/test_cachesize -D ExperimentalMemCheck

Tools:
Ubuntu 19.10, Clang 7,8,9, Gcc 7,8,9, Cmake 3.14

Copyright (c) 2020, Rik Prohaska
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

tokuft test version.  rename tokuft test version to avoid conflict.
bug when the lock memory use is over the limit.  The ydb tests
show that DB->put normally returns TOKUDB_OUT_OF_LOCKS when the
lock memory use is over the limit.
retry occurs and the lock memory use is over the limit, then pending
lock requests should be completed with TOKUDB_OUT_OF_LOCKS result.
The current code does not handle this case and crashes.  This commit
fixes this case and is sufficient to fix PS-4328.
and drd scheduler with fairness (--fair-sched=try).  This should
reduce execution time from minutes to seconds.
It causes helgrind to report false positive data races on tests,
specifically the helgrind_helgrind tests.

4101: ==17113== Possible data race during read of size 1 at 0x52FA980 by thread #1
4101: ==17113== Locks held: 1, at address 0x4C126C0
4101: ==17113==    at 0x483E99C: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_helgrind-amd64-linux.so)
4101: ==17113==    by 0x483EC4A: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_helgrind-amd64-linux.so)
4101: ==17113==    by 0x4A95654: toku_mutex_destroy(toku_mutex_t*) (toku_pthread.h:427)
4101: ==17113==    by 0x4B6CF5C: bjm_destroy(background_job_manager_struct*) (background_job_manager.cc:67)
4101: ==17113==    by 0x4ABE119: write_dirty_pairs_for_close(cachetable*, cachefile*) (cachetable.cc:2406)
4101: ==17113==    by 0x4ABE308: cachetable_flush_cachefile(cachetable*, cachefile*, bool) (cachetable.cc:2493)
4101: ==17113==    by 0x4AB99BE: toku_cachefile_close(cachefile**, bool, __toku_lsn) (cachetable.cc:529)
4101: ==17113==    by 0x4ACD7C2: toku_ft_evict_from_memory(ft*, bool, __toku_lsn) (ft.cc:499)
4101: ==17113==    by 0x4ACEADD: toku_ft_remove_reference(ft*, bool, __toku_lsn, void (*)(ft*, void*), void*) (ft.cc:949)
4101: ==17113==    by 0x4AE9B21: ft_handle_close(ft_handle*, bool, __toku_lsn) (ft-ops.cc:3272)
4101: ==17113==    by 0x4AE9B54: toku_ft_handle_close(ft_handle*) (ft-ops.cc:3280)
4101: ==17113==    by 0x4A8CD68: toku_db_close(__toku_db*) (ydb_db.cc:212)
4101: ==17113==
4101: ==17113== This conflicts with a previous write of size 4 by thread #10
4101: ==17113== Locks held: none
4101: ==17113==    at 0x4C557A1: __pthread_mutex_unlock_usercnt (pthread_mutex_unlock.c:51)
4101: ==17113==    by 0x4C557A1: pthread_mutex_unlock (pthread_mutex_unlock.c:357)
4101: ==17113==    by 0x483F458: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_helgrind-amd64-linux.so)
4101: ==17113==    by 0x4A84508: toku_mutex_unlock(toku_mutex_t*) (toku_pthread.h:256)
4101: ==17113==    by 0x4B6D0EC: bjm_remove_background_job(background_job_manager_struct*) (background_job_manager.cc:98)
4101: ==17113==    by 0x4ABDCDD: cachetable_flush_pair_for_close(void*) (cachetable.cc:2327)
4101: ==17113==    by 0x4B7D785: work_on_kibbutz(void*) (kibbutz.cc:154)
4101: ==17113==    by 0x4841B1A: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_helgrind-amd64-linux.so)
4101: ==17113==    by 0x4C51668: start_thread (pthread_create.c:479)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant