Merge branch 'master' into fix-regioncache-inconsistency-access

This commit is contained in:
ekexium 2022-06-15 19:05:56 +08:00 committed by GitHub
commit 1781327bc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 30 deletions

View File

@ -17,6 +17,8 @@ jobs:
profile: minimal
toolchain: nightly
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@v1.4.0
- uses: actions-rs/cargo@v1
with:
command: check
@ -47,6 +49,8 @@ jobs:
toolchain: nightly
components: clippy
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@v1.4.0
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
@ -64,18 +68,8 @@ jobs:
profile: minimal
toolchain: nightly
override: true
- run: cargo generate-lockfile
- name: Cache dependencies
uses: actions/cache@v2
env:
cache-name: cache-dependencies
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/registry/index
~/.cargo/registry/cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
- name: Rust Cache
uses: Swatinem/rust-cache@v1.4.0
- name: unit test
run: make unit-test
integration-test:
@ -90,21 +84,18 @@ jobs:
profile: minimal
toolchain: nightly
override: true
- run: cargo generate-lockfile
- name: Cache dependencies
uses: actions/cache@v2
env:
cache-name: cache-dependencies
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/registry/index
~/.cargo/registry/cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
- name: Rust Cache
uses: Swatinem/rust-cache@v1.4.0
- name: install tiup
run: curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
- name: start tiup playground
run: /home/runner/.tiup/bin/tiup playground nightly --mode tikv-slim --kv 3 --without-monitor --kv.config /home/runner/work/client-rust/client-rust/config/tikv.toml --pd.config /home/runner/work/client-rust/client-rust/config/pd.toml &
run: |
~/.tiup/bin/tiup install tikv:nightly pd:nightly
~/.tiup/bin/tiup playground nightly --mode tikv-slim --kv 3 --without-monitor --kv.config config/tikv.toml --pd.config config/pd.toml &
while :; do
echo "waiting cluster to be ready"
[[ "$(curl -I http://127.0.0.1:2379/pd/api/v1/regions 2>/dev/null | head -n 1 | cut -d$' ' -f2)" -ne "405" ]] || break
sleep 1
done
- name: integration test
run: MULTI_REGION=1 make integration-test

View File

@ -4,7 +4,7 @@ region-split-keys = 7
batch-split-limit = 100
[raftstore]
region-split-check-diff = "0KB"
region-split-check-diff = "1B"
pd-heartbeat-tick-interval = "2s"
pd-store-heartbeat-tick-interval = "5s"
split-region-check-tick-interval = "1s"

View File

@ -27,6 +27,7 @@ async fn main() -> Result<()> {
// When we first create a client we receive a `Connect` structure which must be resolved before
// the client is actually connected and usable.
let client = Client::new_with_config(args.pd, config, None).await?;
let client = client.clone();
// Requests are created from the connected client. These calls return structures which
// implement `Future`. This means the `Future` must be resolved before the action ever takes

View File

@ -8,7 +8,7 @@ use std::{path::PathBuf, time::Duration};
///
/// See also [`TransactionOptions`](crate::TransactionOptions) which provides more ways to configure
/// requests.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(default)]
#[serde(rename_all = "kebab-case")]
pub struct Config {

View File

@ -25,7 +25,6 @@ const MAX_RAW_KV_SCAN_LIMIT: u32 = 10240;
///
/// The returned results of raw request methods are [`Future`](std::future::Future)s that must be
/// awaited to execute.
#[derive(Clone)]
pub struct Client<PdC: PdClient = PdRpcClient> {
rpc: Arc<PdC>,
cf: Option<ColumnFamily>,
@ -34,6 +33,17 @@ pub struct Client<PdC: PdClient = PdRpcClient> {
logger: Logger,
}
impl Clone for Client {
fn clone(&self) -> Self {
Self {
rpc: self.rpc.clone(),
cf: self.cf.clone(),
atomic: self.atomic,
logger: self.logger.clone(),
}
}
}
impl Client<PdRpcClient> {
/// Create a raw [`Client`] and connect to the TiKV cluster.
///

View File

@ -38,6 +38,15 @@ pub struct Client {
logger: Logger,
}
impl Clone for Client {
fn clone(&self) -> Self {
Self {
pd: self.pd.clone(),
logger: self.logger.clone(),
}
}
}
impl Client {
/// Create a transactional [`Client`] and connect to the TiKV cluster.
///

View File

@ -953,7 +953,7 @@ pub struct TransactionOptions {
heartbeat_option: HeartbeatOption,
}
#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum HeartbeatOption {
NoHeartbeat,
FixedTime(Duration),
@ -1308,7 +1308,7 @@ impl<PdC: PdClient> Committer<PdC> {
}
}
#[derive(PartialEq)]
#[derive(PartialEq, Eq)]
enum TransactionStatus {
/// The transaction is read-only [`Snapshot`](super::Snapshot), no need to commit or rollback or panic on drop.
ReadOnly,