mariadb/storage/tokudb/PerconaFT
Kristian Nielsen d145d1b6ee fix bogus stalls in the lock tree for low concurrency applications
Merge into the MariaDB tree the pull request from Rich Prohaska for
PerconaFT. These changes are needed to get parallel replication to
work with TokuDB. Once the pull request is accepted by Percona and the new upstream version enters MariaDB, this commit can be superseded.

Original commit message from Rich Prohaska:

    1. Fix the release before wait race

    The release before wait race occurs when a lock is released by transaction A after transaction B tried to acquire it but before transaction B has a chance to register it's pending lock request.  There are several ways to fix this problem, but we want to optimize for the common situation of minimal lock conflicts, which is what the lock acquisition algorithm currently does.  Our solution to the release before wait race is for transaction B to retry its lock request after its lock request has been added to the pending lock set.

    2. Fix the retry race

    The retry race occurs in the current lock retry algorithm which assumes that if some transaction is running lock retry, then my transaction does not also need to run it.  There is a chance that some pending lock requests will be skipped, but these lock requests will eventually time out.  For applications with small numbers of concurrent transactions, timeouts will frequently occur, and the application throughput will be very small.

    The solution to the retry race is to use a group retry algorithm.  All threads run through the retry logic.  Sequence numbers are used to group retries into batches such that one transaction can run the retry logic on behalf of several transactions.  This amortizes the retry cost.  The sequence numbers also ensure that when a transaction releases its locks, all of the pending lock requests that it is blocking are retried.

    3. Implement a mechanism to find and kill a pending lock request

    Tags lock requests with a client id, use the client id as a key into the pending lock requests sets to find a lock request, complete the lock request with a lock timeout error.

    Copyright (c) 2016, Rich 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:

    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

    2. 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.
2016-11-23 16:48:31 +01:00
..
buildbot 5.6.26-74.0 2015-10-26 12:57:57 +01:00
buildheader fix bogus stalls in the lock tree for low concurrency applications 2016-11-23 16:48:31 +01:00
cmake 5.6.26-74.0 2015-10-26 12:57:57 +01:00
cmake_modules Merge branch '10.0-galera' into 10.1 2016-11-02 13:44:07 +01:00
ft fix bogus stalls in the lock tree for low concurrency applications 2016-11-23 16:48:31 +01:00
ftcxx 5.6.30-76.3 2016-06-10 19:47:58 +02:00
locktree fix bogus stalls in the lock tree for low concurrency applications 2016-11-23 16:48:31 +01:00
portability Merge branch 'merge/merge-tokudb-5.6' into 10.0 2016-10-25 21:58:59 +02:00
scripts Merge branch 'merge-tokudb-5.6' into 10.0-tokudb-merge 2016-06-11 01:06:09 +02:00
src fix bogus stalls in the lock tree for low concurrency applications 2016-11-23 16:48:31 +01:00
third_party Merge branch 'merge/merge-tokudb-5.6' into 10.0 2016-09-27 19:03:11 +02:00
tools Merge branch 'merge/merge-tokudb-5.6' into 10.0 2016-09-27 19:03:11 +02:00
util Merge branch 'merge/merge-tokudb-5.6' into 10.0 2016-09-27 19:03:11 +02:00
bash.suppressions 5.6.26-74.0 2015-10-26 12:57:57 +01:00
CMakeLists.txt Merge branch 'merge-tokudb-5.6' into 10.0-tokudb-merge 2016-06-10 20:48:59 +02:00
COPYING.AGPLv3 5.6.26-74.0 2015-10-26 12:57:57 +01:00
COPYING.GPLv2 5.6.26-74.0 2015-10-26 12:57:57 +01:00
CTestConfig.cmake 5.6.26-74.0 2015-10-26 12:57:57 +01:00
CTestCustom.cmake.in 5.6.27-76.0 2015-12-15 17:23:58 +01:00
DartConfig.cmake 5.6.26-74.0 2015-10-26 12:57:57 +01:00
PATENTS 5.6.26-74.0 2015-10-26 12:57:57 +01:00
README.md 5.6.28-76.1 2016-02-16 19:44:10 +01:00

PerconaFT

PerconaFT is a high-performance, transactional key-value store, used in the TokuDB storage engine for Percona Server and MySQL, and in TokuMX, the high-performance MongoDB distribution.

PerconaFT is provided as a shared library with an interface similar to Berkeley DB.

To build the full MySQL product, see the instructions for Percona/tokudb-engine. To build TokuMX, see the instructions for Percona/percona-server-mongodb. This document covers PerconaFT only.

Building

PerconaFT is built using CMake >= 2.8.9. Out-of-source builds are recommended. You need a C++11 compiler, though only GCC >= 4.7 and Apple's Clang are tested. You also need zlib development packages (yum install zlib-devel or apt-get install zlib1g-dev).

You will also need the source code for jemalloc, checked out in third_party/.

git clone git://github.com/Percona/PerconaFT.git percona-ft
cd percona-ft
git clone git://github.com/Percona/jemalloc.git third_party/jemalloc
mkdir build
cd build
CC=gcc47 CXX=g++47 cmake \
    -D CMAKE_BUILD_TYPE=Debug \
    -D BUILD_TESTING=OFF \
    -D USE_VALGRIND=OFF \
    -D CMAKE_INSTALL_PREFIX=../prefix/ \
    ..
cmake --build . --target install

This will build libtokudb.so and libtokuportability.so and install it, some header files, and some examples to percona-ft/prefix/. It will also build jemalloc and install it alongside these libraries, you should link to that if you are planning to run benchmarks or in production.

Platforms

PerconaFT is supported on 64-bit Centos, should work on other 64-bit linux distributions, and may work on OSX 10.8 and FreeBSD. PerconaFT is not supported on 32-bit systems.

Transparent hugepages is a feature in newer linux kernel versions that causes problems for the memory usage tracking calculations in PerconaFT and can lead to memory overcommit. If you have this feature enabled, PerconaFT will not start, and you should turn it off. If you want to run with transparent hugepages on, you can set an environment variable TOKU_HUGE_PAGES_OK=1, but only do this for testing, and only with a small cache size.

Testing

PerconaFT uses CTest for testing. The CDash testing dashboard is not currently public, but you can run the tests without submitting them.

There are some large data files not stored in the git repository, that will be made available soon. For now, the tests that use these files will not run.

In the build directory from above:

cmake -D BUILD_TESTING=ON ..
ctest -D ExperimentalStart \
      -D ExperimentalConfigure \
      -D ExperimentalBuild \
      -D ExperimentalTest

Contributing

Please report bugs in PerconaFT to the issue tracker.

We have two publicly accessible mailing lists for TokuDB:

and two for TokuMX:

All source code and test contributions must be provided under a BSD 2-Clause license. For any small change set, the license text may be contained within the commit comment and the pull request. For larger contributions, the license must be presented in a COPYING.<feature_name> file in the root of the PerconaFT project. Please see the BSD 2-Clause license template for the content of the license text.

License

PerconaFT is available under the GPL version 2, and AGPL version 3. See COPYING.AGPLv3, COPYING.GPLv2, and PATENTS.