Git Product home page Git Product logo

client-go's Introduction

tikv_logo

Build Status Coverage Status CII Best Practices

TiKV is an open-source, distributed, and 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 by PingCAP to complement TiDB, a distributed HTAP database compatible with the MySQL protocol.

The design of TiKV ('Ti' stands for titanium) 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.

If you're interested in contributing to TiKV, or want to build it from source, see CONTRIBUTING.md.

cncf_logo cncf_logo

TiKV is a graduated project of 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.

Governance

See Governance.

Documentation

For instructions on deployment, configuration, and maintenance of TiKV,see TiKV documentation on our website. For more details on concepts and designs behind TiKV, see Deep Dive TiKV.

Note:

We have migrated our documentation from the TiKV's wiki page to the official website. The original Wiki page is discontinued. If you have any suggestions or issues regarding documentation, offer your feedback here.

TiKV adopters

You can view the list of TiKV Adopters.

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.

Quick start

Deploy a playground with TiUP

The most quickest to try out TiKV with TiDB is using TiUP, a component manager for TiDB.

You can see this page for a step by step tutorial.

Deploy a playground with binary

TiKV is able to run separately with PD, which is the minimal deployment required.

  1. Download and extract binaries.
$ export TIKV_VERSION=v7.5.0
$ export GOOS=darwin  # only {darwin, linux} are supported
$ export GOARCH=amd64 # only {amd64, arm64} are supported
$ curl -O  https://tiup-mirrors.pingcap.com/tikv-$TIKV_VERSION-$GOOS-$GOARCH.tar.gz
$ curl -O  https://tiup-mirrors.pingcap.com/pd-$TIKV_VERSION-$GOOS-$GOARCH.tar.gz
$ tar -xzf tikv-$TIKV_VERSION-$GOOS-$GOARCH.tar.gz
$ tar -xzf pd-$TIKV_VERSION-$GOOS-$GOARCH.tar.gz
  1. Start PD instance.
$ ./pd-server --name=pd --data-dir=/tmp/pd/data --client-urls="http://127.0.0.1:2379" --peer-urls="http://127.0.0.1:2380" --initial-cluster="pd=http://127.0.0.1:2380" --log-file=/tmp/pd/log/pd.log
  1. Start TiKV instance.
$ ./tikv-server --pd-endpoints="127.0.0.1:2379" --addr="127.0.0.1:20160" --data-dir=/tmp/tikv/data --log-file=/tmp/tikv/log/tikv.log
  1. Install TiKV Client(Python) and verify the deployment, required Python 3.5+.
$ pip3 install -i https://test.pypi.org/simple/ tikv-client
from tikv_client import RawClient

client = RawClient.connect("127.0.0.1:2379")

client.put(b'foo', b'bar')
print(client.get(b'foo')) # b'bar'

client.put(b'foo', b'baz')
print(client.get(b'foo')) # b'baz'

Deploy a cluster with TiUP

You can see this manual of production-like cluster deployment presented by @c4pt0r.

Build from source

See CONTRIBUTING.md.

Client drivers

If you want to try the Go client, see Go Client.

Security

Security audit

A third-party security auditing was performed by Cure53. See the full report here.

Reporting Security Vulnerabilities

To report a security vulnerability, please send an email to TiKV-security group.

See Security for the process and policy followed by the TiKV project.

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.

Social Media

Slack

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

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.

client-go's People

Contributors

andremouche avatar bufferflies avatar cabinfeverb avatar cfzjywxk avatar crazycs520 avatar defined2014 avatar dependabot[bot] avatar disksing avatar ekexium avatar glorv avatar guo-shaoge avatar hawkingrei avatar husharp avatar iosmanthus avatar jackysp avatar jmpotato avatar lance6716 avatar lysu avatar myonkeminta avatar nolouch avatar smityz avatar sticnarf avatar tiancaiamao avatar tisonkun avatar windtalker avatar yisaer avatar you06 avatar youjiali1995 avatar ystaticy avatar zyguan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

client-go's Issues

Empty value is not supported

It is a historical problem. This client is extracted from TiDB. In TiDB, every key has a non-empty value. In the implementation, the client treats an empty value as the key does not exist, and it also rejects putting a pair with empty value.

But TiKV actually supports a key with zero-length value. The user can put a key with an empty value with another client (e.g. client-rust). Then, they will find the key does not exist when reading with this client.

cc @andylokandy @disksing

Add PrefixNextKey API on v2 branch

PrefixNextKey returns the next prefix key.

Assume there are keys like:

  • rowkey1
  • rowkey1_column1
  • rowkey1_column2
  • rowKey2

If we seek 'rowkey1' NextKey, we will get 'rowkey1_column1'.
If we seek 'rowkey1' PrefixNextKey, we will get 'rowkey2'.

Why no tag on this package?

Hello,

Why no tag on this package? How to lock the version of this client?

Suggest to add release tag on it, then we will upgrade it by minor/patch.

Best Regards

how about vendoring pingcap/pd/client?

Problems

I'm trying to use the client-go(rawkv client) to read/write data from/to write CF(not only default CF). However, I run into someย problems.

In my project, I use tikv/client-go -- rawkv client to read the write CF to get a key-value, which is written by TiDB server. I use the latest pingcap/tidb -- tablecodec/codec to encode and decode those keys and values. And the problem is that pingcap/tidb depends on a recent pingcap/pd and client-go depends on a old version pingcap/pd. We can't put two version pingcap/pd in one project because pd-client will register unqiue metrics collector during packge init.
https://github.com/tikv/pd/blob/fc997de0ae38c22dfaab0979dc0f64a66689b286/client/metrics.go#L47-L51
If we have two versions, it panic like this

panic: duplicate metrics collector registration attempted

goroutine 1 [running]:
github.com/prometheus/client_golang/prometheus.(*Registry).MustRegister(0xc000180be0, 0xc000076f40, 0x1, 0x1)
        /home/cosven/go/pkg/mod/github.com/prometheus/[email protected]/prometheus/registry.go:400 +0xad
github.com/prometheus/client_golang/prometheus.MustRegister(...)
        /home/cosven/go/pkg/mod/github.com/prometheus/[email protected]/prometheus/registry.go:177
github.com/tikv/client-go/pd.init.0()
        /home/cosven/coding/client-go/pd/metrics.go:35 +0x91

Ways I Tried

I have tried to upgrade pingcap/pd in client-go, but it failed. It is really hard to upgrade pingcap/pd in client-go because the recent pd.Client interface in pingcap/pd has many changes(for example, many more methods to implement).

Suggested solution

I find that client-go only depends the pd.Client part in pingcap/pd. I think client-go need not to depend on pingcap/pd and vendoring pingcap/pd/client maybe a good idea. pd/client is relative simple and vendoring pingcap/pd/client will bring much convenience for maintaintence.

I'm happy to submit a PR if this is right way to go.

go get tidb version

I'm not sure whether I should file here or in docs. But I follow the document to start using the go client

go get github.com/pingcap/tidb@master
go build

go get downloads [email protected]+incompatible. The during go build, it gives out this error:
/[email protected]+incompatible/store/tikv/kv.go:28:2: unknown import path "github.com/pingcap/pd/pd-client": cannot find module providing package github.com/pingcap/pd/pd-client

I fix this problem by reinitialize the project with

go get github.com/pingcap/[email protected]

if tx.Commit failed with an error, should this transaction be rollback explicitly?

the example in https://github.com/tikv/client-go/blob/master/examples/txnkv/txnkv.go#L64
if tx.Commit returns an err, shoud this transaction be rollback explicitly?

what is the different between:

	tx, err := client.Begin(context.TODO())
	if err != nil {
		return err
	}

	for i := 0; i < len(args); i += 2 {
		key, val := args[i], args[i+1]
		err := tx.Set(key, val)
		if err != nil {
                        tx.Rollback()
			return err
		}
	}
	err  = tx.Commit(context.Background())
        if err != nil {
                tx.Rollback()
               return err
        }
        return nil

and

	tx, err := client.Begin(context.TODO())
	if err != nil {
		return err
	}

	for i := 0; i < len(args); i += 2 {
		key, val := args[i], args[i+1]
		err := tx.Set(key, val)
		if err != nil {
			return err
		}
	}
	return tx.Commit(context.Background())

Is it ready for production use

Before we use the TiDB Go client as the driver to implement our own tikv-proxy, now we want to replace it with the native client-go driver here. Is it ready for production use? If yes, please add a README, thanks!

go get tikv/client-go/config fails with go 1.13

while getting the go get tikv/client-go/config fails with the below issue on go 1.13

go: finding github.com/tikv/client-go latest
go: finding github.com/tikv/client-go/rawkv latest
go: finding github.com/tikv/client-go/config latest
go: github.com/tikv/[email protected] requires
github.com/tikv/[email protected] requires
github.com/pingcap-incubator/[email protected] requires
gopkg.in/oleiade/[email protected]: go.mod has non-....v1 module path "github.com/oleiade/reflections" at revision v1.0.0

All methods that do IO should take context.Context as arguments

Some methods, such as TiKVSnapshot.Get, perform I/O using a context.Background(). This is non-desirable since if I/O is done in response to a client request, and the request is canceled/timesout then the TiKV operation will continue processing, and thus consuming up background resources.

Add more examples

We need more examples to illustrate how to use client-go.

  • basic txnkv
  • basic rawkv
  • options usage
  • run GC
  • set up metrics
  • configurations
  • advanced utilities: lock resolver / delete range / split range

[pd] failed updateLeader

Hi all,
I ran example in file rawkv.go, but it not ran and it have errors:

INFO[0000] [pd] create pd client with endpoints [127.0.0.1:32771] 
INFO[0000] [pd] leader switches to: http://pd2:2379, previous:  
INFO[0000] [pd] init cluster id 6718973635215653867     
cluster ID: 6718973635215653867
ERRO[0000] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection 
error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0000] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0000] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0000] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0001] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection 
error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0001] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0001] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0002] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection 
error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0002] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0003] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection 
error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0003] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0003] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0004] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection 
error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0004] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0004] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0005] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0005] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0006] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0006] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0007] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0007] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0007] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0008] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0008] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0009] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0009] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0009] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0010] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0010] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0011] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0011] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0011] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0012] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0012] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0013] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0013] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0014] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0014] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0014] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0015] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0015] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0016] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0016] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0016] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0017] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0017] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0018] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0018] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0018] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0019] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0019] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
ERRO[0020] [pd] create tso stream error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" 
ERRO[0020] [pd] failed updateLeader: failed to get leader from [http://pd0:2379 http://pd1:2379 http://pd2:2379] 
WARN[0020] backoffer.maxSleep 20000ms is exceeded, errors:
loadRegion from PD failed, key: "Company", err: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" at 2019-07-29T15:40:57.052765+07:00
loadRegion from PD failed, key: "Company", err: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" at 2019-07-29T15:40:58.853341+07:00
loadRegion from PD failed, key: "Company", err: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp: lookup pd2: no such host" at 2019-07-29T15:41:00.548358+07:00 
panic: pdRPC

goroutine 1 [running]:

I used https://github.com/pingcap/tidb-docker-compose to deploy. And I edited address in file rawkv.go:

cli, err := rawkv.NewClient(context.TODO(), []string{"127.0.0.1:32771"}, config.Default())

When i used example by TiDB docker-compose, it success. So I don't know if this error is with you or theTiDB docker-compose.

Replace `github.com/pingcap/check` with `https://github.com/stretchr/testify`

testify is more widely used and tools friendly.

  • /client
  • /config
  • /latch
  • /locate
  • /mockstore, /mockstore/deadlock
  • /mockstore/mocktikv
  • /oracle/oracles
  • /tikv
  • /unionstore/memdb{,_norace}_test.go
  • /integration_tests/1pc_test.go
  • /integration_tests/2pc{,_slow,_fail}_test.go
  • /integration_tests/async_commit{,_fail}_test.go
  • /integration_tests/{delete_range,isolation}_test.go
  • /integration_tests/lock_test.go
  • /integration_tests/range_task_test.go
  • /integration_tests/rawkv_test.go
  • /integration_tests/{safepoint,scan,scan_mock}_test.go
  • /integration_tests/snapshot{,_fail}_test.go
  • /integration_tests/split_test.go
  • /integration_tests/store{,_fail}_test.go
  • /integration_tests/ticlient{,_slow}_test.go

Add compatibility tests

It is hard to know if code modifications break projects that using client-go. We can add some tests in CI to check if projects like tidb or br can build.

Multiple go clients

I am totally confused there seems to be two Go clients in existence:

  1. github.com/tikv/client-go which you would think is the preferred and most up-to-date as it is part of the github.com/tikv project account
    and
  2. github.com/pingcap/tidb/store/tikv which is used in the tikv.org documentation linked to by https://github.com/tikv/tikv

Can you explain (maybe add to a readme on tikv/client-go) the difference, pros and cons of using either, clarify which is the recommended to be used.

Support configure clients separatly

Currently, we use global configuration, which means all clients in a process share the same configuration. We can introduce some configuration arguments when creating a client.

Locking a key

Hi,

I want to lock a key so that it cannot be edited in another transaction. I have looked at LockKeys() but looking at the implementation this doesn't seem to do what I want.

The only way I have been able to achieve this is by setting the value to what it already is and having it as part of the transaction. This means I have to read the value and then write it.

Something like below:

func TestLock(t *testing.T) {
	client, err := txnkv.NewClient(context.TODO(), []string{"127.0.0.1:2379"}, config.Default())
	require.NoError(t, err)

	txn, err := client.Begin(context.TODO())
	require.NoError(t, err)

	txn1, err := client.Begin(context.TODO())
	require.NoError(t, err)
	require.NoError(t, txn1.Set([]byte("bar"), []byte{'0'}))
	require.NoError(t, txn1.Commit(context.TODO()))

	require.NoError(t, txn.Set([]byte("bar"), []byte{'0'}))
	require.NoError(t, txn.Commit(context.TODO()))

}

Is there nothing I could do such as

func TestLock(t *testing.T) {
	client, err := txnkv.NewClient(context.TODO(), []string{"127.0.0.1:2379"}, config.Default())
	require.NoError(t, err)

	txn, err := client.Begin(context.TODO())
	require.NoError(t, err)

	txn1, err := client.Begin(context.TODO())
	require.NoError(t, err)
	require.NoError(t, txn1.LockKeys([]byte("bar")))
	require.NoError(t, txn1.Commit(context.TODO()))

	require.NoError(t, txn.Set([]byte("bar"), []byte{'0'}))
	require.NoError(t, txn.Commit(context.TODO()))

}
``` that would achieve the same?

Build error: undefined: push.AddFromGatherer

Hello. Thanks for the library. But I've got an error:

vendor/github.com/tikv/client-go/metrics/push.go:44:10: undefined: push.AddFromGatherer

push.AddFromGatherer was removed from prometheus client in release 1.0.0.

Logrus instances and override

In our codebase, we have 2 to 3 instances of TiKV in certain circumstances. All of them are currently logging through the logrus standard logger.

It would be preferable if each tikv-client instance had his own logger attached to it so it would be possible to configure them differently based on the instance directly.

Every logger could use the standard logger by default and a new method could enable configure a different logger by default.

I'm opening the issue here to get a feeling if this would be an accept PR on this repository, at some point in time, I could take the issue and make the necessary code changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.