Skip to content
Distributed transactional key-value database, originally created to complement TiDB
Branch: master
Clone or download
hicqu raftstore: mark read delegate as invalid correctly (#4765)
Signed-off-by: qupeng <qupeng@pingcap.com>
Latest commit 8e6e4d5 May 25, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Fix CI by installing tarpaulin from git, so that Cargo.lock is not ig… Sep 10, 2018
.github github: update pull request template (#4555) Apr 26, 2019
benches coprocessor: move ExecSummaryCollector out of Executors into a wrappe… May 24, 2019
ci-build Change Copyright holders to the TiKV Authors (#4438) Apr 11, 2019
components raftstore: hibernate regions (#4591) May 23, 2019
docs Update roadmap (#4487) Apr 10, 2019
etc PD Connection: Retry for infinity, log periodically (#4502) May 24, 2019
fuzz [WIP] Add more fuzz tests (#4608) Apr 30, 2019
images images: update logo with a high resolution and transparent background ( May 21, 2019
scripts Add match_template to jemalloc whitelist (#4725) May 20, 2019
src raftstore: mark read delegate as invalid correctly (#4765) May 25, 2019
tests raftstore: mark read delegate as invalid correctly (#4765) May 25, 2019
.dockerignore produce an Alpine Linux image (#3697) Oct 23, 2018
.gitignore Cargo profiles with faster compile times (#4415) Mar 31, 2019
CHANGELOG.md raftstore: hibernate regions (#4591) May 23, 2019
CODE_COMMENT_STYLE.md re-add comment style guide for merge (#4259) Feb 22, 2019
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md (#4216) Feb 15, 2019
CONTRIBUTING.md *: update contributing guide (#4325) Mar 12, 2019
Cargo.lock Use ordered-float as the Real implementation in batch executors (#4729) May 21, 2019
Cargo.toml raftstore: hibernate regions (#4591) May 23, 2019
Dockerfile Introduce match_template to simplify code (#4726) May 21, 2019
GOVERNANCE.md Add governance (#4261) Mar 18, 2019
Jenkinsfile Jenkinsfile: init adding Jenkinsfile (#1835) May 15, 2017
LICENSE *: add license Apr 2, 2016
MAINTAINERS.md Add @sunxiaoguang to MAINTAINERS.md (#4397) Mar 26, 2019
Makefile *: remove make bench target (#4697) May 23, 2019
README.md readme: update readme logo's resolution (#4713) May 20, 2019
rust-toolchain *: Upgrade Rust compiler version to 2019-04-25. (#4568) Apr 25, 2019

README.md

tikv_logo

Build Status Coverage Status GitHub release CII Best Practices

TiKV ("Ti" stands for Titanium) is an open source distributed transactional key-value database. Unlike other traditional NoSQL systems, TiKV not only provides classical key-value APIs, but also transactional APIs with ACID compliance. Built in Rust and powered by Raft, TiKV was originally created to complement TiDB, a distributed HTAP database compatible with the MySQL protocol.

The design of TiKV is inspired by some great distributed systems from Google, such as BigTable, Spanner, and Percolator, and some of the latest achievements in academia in recent years, such as the Raft consensus algorithm.

cncf_logo

TiKV is hosted by the Cloud Native Computing Foundation (CNCF). If you are an organization that wants to help shape the evolution of technologies that are container-packaged, dynamically-scheduled and microservices-oriented, consider joining the CNCF. For details about who's involved and how TiKV plays a role, read the CNCF announcement.


With the implementation of the Raft consensus algorithm in Rust and consensus state stored in RocksDB, TiKV guarantees data consistency. Placement Driver (PD), which is introduced to implement auto-sharding, enables automatic data migration. The transaction model is similar to Google's Percolator with some performance improvements. TiKV also provides snapshot isolation (SI), snapshot isolation with lock (SQL: SELECT ... FOR UPDATE), and externally consistent reads and writes in distributed transactions.

TiKV has the following key features:

  • Geo-Replication

    TiKV uses Raft and the Placement Driver to support Geo-Replication.

  • Horizontal scalability

    With PD and carefully designed Raft groups, TiKV excels in horizontal scalability and can easily scale to 100+ TBs of data.

  • Consistent distributed transactions

    Similar to Google's Spanner, TiKV supports externally-consistent distributed transactions.

  • Coprocessor support

    Similar to Hbase, TiKV implements a coprocessor framework to support distributed computing.

  • Cooperates with TiDB

    Thanks to the internal optimization, TiKV and TiDB can work together to be a compelling database solution with high horizontal scalability, externally-consistent transactions, support for RDBMS, and NoSQL design patterns.

TiKV Adopters

You can view the list of TiKV Adopters.

TiKV Roadmap

You can see the TiKV Roadmap.

TiKV software stack

The TiKV software stack

  • Placement Driver: PD is the cluster manager of TiKV, which periodically checks replication constraints to balance load and data automatically.
  • Store: There is a RocksDB within each Store and it stores data into the local disk.
  • Region: Region is the basic unit of Key-Value data movement. Each Region is replicated to multiple Nodes. These multiple replicas form a Raft group.
  • Node: A physical node in the cluster. Within each node, there are one or more Stores. Within each Store, there are many Regions.

When a node starts, the metadata of the Node, Store and Region are recorded into PD. The status of each Region and Store is reported to PD regularly.

Try TiKV

TiKV was originally a component of TiDB. To run TiKV you must build and run it with PD, which is used to manage a TiKV cluster. You can use TiKV together with TiDB or separately on its own.

We provide multiple deployment methods, but it is recommended to use our Ansible deployment for production environment. The TiKV documentation is available on TiKV's wiki page.

Testing deployment

Production deployment

For the production environment, use Ansible to deploy the cluster.

Client drivers

Currently, the only interface to TiKV is the TiDB Go client and the TiSpark Java client.

If you want to try the Go client, see Try Two Types of APIs.

Setting up a development workspace

The TiKV codebase is primarily written in Rust, but has components written in C++ (RocksDB) and Go (gRPC). To provide consistency and avoid opinion-based arguments, we make extensive use of linters and automated formatting tools. Additionally, due to Rust's youth we are currently utilizing nightly builds which provide access to many useful features.

Checking your prerequisites

To build TiKV you'll need to at least have the following installed:

  • git - Version control
  • rustup - Rust toolchain manager
  • awk - Pattern scanning/processing language
  • cmake - Build tool (required for gRPC)
  • go - Programming language (required for gRPC)
  • make - Build tool (run common workflows)
  • clang or gcc - C compiler toolchain

Getting the repository

git clone https://github.com/tikv/tikv.git
cd tikv
# Future instructions assume you are in this repository

Configuring your Rust toolchain

rustup is an official toolchain manager for Rust, similar to rvm or rbenv from the Ruby world.

TiKV uses the version of the Rust toolchain specified in rust-toolchain. rustup and cargo will automatically utilize this file. We also make use of the rustfmt and clippy components.

rustup component add rustfmt-preview

Building & testing

While TiKV includes a Makefile with common workflows, you are also able to use cargo as you would in a normal Rust project.

At this point, you can build TiKV:

make build

During interactive development, you may prefer using cargo check, which will do parse, borrow check, and lint run on your code, but not actually compile it. It is particularly handy alongside cargo-watch which will run a command each time you change a file.

cargo install cargo-watch
cargo watch -s "cargo check"

When you're ready to test out your changes, use the dev task. It will format your codebase, build with clippy enabled, and run tests. This should run without failure before you create a PR.

make dev

You can run the full test suite locally, or just run a specific test:

# Run the full suite
make test
# Run a specific test
cargo test $TESTNAME

Our CI systems automatically test all the pull requests, so making sure the full suite passes the test before creating your PR is not strictly required. All merged PRs must have passed CI test.

Getting the rest of the system working

To get other components (TiDB and PD) working, we suggest you follow the development guide, because you need the pd-server at least to work alongside tikv-server for integration level testing.

Configuration

Read our configuration guide to learn about various configuration options.

Contributing

Contributions are welcome! See CONTRIBUTING for details on submitting patches and the contribution workflow.

For beginners, we have prepared many suitable tasks for you. Checkout our Help Wanted issues for a list, in which we have also marked the difficulty level.

If you are planning something big, for example, relates to multiple components or changes current behaviors, make sure to open an issue to discuss with us before going on.

The TiKV team actively develops and maintains a bunch of dependencies used in TiKV, which you may be also interested in:

  • rust-prometheus: The Prometheus client for Rust, our metrics collecting and reporting library
  • rust-rocksdb: Our RocksDB binding and wrapper for Rust
  • raft-rs: The Raft distributed consensus algorithm implemented in Rust
  • grpc-rs: The gRPC library for Rust built on the gRPC C Core library and Rust Futures
  • fail-rs: Fail points for Rust

Communication

Communication within the TiKV community abides by TiKV Code of Conduct. Here is an excerpt:

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

Socia Media

Slack

Join the TiKV community on Slack - Sign up and join channels on TiKV topics that interest you.

WeChat

The TiKV community is also available on WeChat, a very popular messaging and social media application in China. If you want to join our WeChat group, send a request mail to zhangyanqing@pingcap.com, with your personal information that includes the following:

  • WeChat ID (Required)
  • PR you submitted to TiKV Repos (Required)
  • Other basic information

We will invite you in right away.

License

TiKV is under the Apache 2.0 license. See the LICENSE file for details.

Acknowledgments

  • Thanks etcd for providing some great open source tools.
  • Thanks RocksDB for their powerful storage engines.
  • Thanks rust-clippy. We do love the great project.
You can’t perform that action at this time.