Skip to content

Commit 60585f6

Browse files
committed
resolve conflict from master
Signed-off-by: iosmanthus <[email protected]>
2 parents dd1c7b9 + e9d0dcd commit 60585f6

File tree

9 files changed

+206
-68
lines changed

9 files changed

+206
-68
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
profile: minimal
1818
toolchain: nightly
1919
override: true
20+
- name: Rust Cache
21+
uses: Swatinem/[email protected]
2022
- uses: actions-rs/cargo@v1
2123
with:
2224
command: check
@@ -47,6 +49,8 @@ jobs:
4749
toolchain: nightly
4850
components: clippy
4951
override: true
52+
- name: Rust Cache
53+
uses: Swatinem/[email protected]
5054
- uses: actions-rs/clippy-check@v1
5155
with:
5256
token: ${{ secrets.GITHUB_TOKEN }}
@@ -64,18 +68,8 @@ jobs:
6468
profile: minimal
6569
toolchain: nightly
6670
override: true
67-
- run: cargo generate-lockfile
68-
- name: Cache dependencies
69-
uses: actions/cache@v2
70-
env:
71-
cache-name: cache-dependencies
72-
with:
73-
path: |
74-
~/.cargo/.crates.toml
75-
~/.cargo/.crates2.json
76-
~/.cargo/registry/index
77-
~/.cargo/registry/cache
78-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
71+
- name: Rust Cache
72+
uses: Swatinem/[email protected]
7973
- name: unit test
8074
run: make unit-test
8175
integration-test:
@@ -90,21 +84,18 @@ jobs:
9084
profile: minimal
9185
toolchain: nightly
9286
override: true
93-
- run: cargo generate-lockfile
94-
- name: Cache dependencies
95-
uses: actions/cache@v2
96-
env:
97-
cache-name: cache-dependencies
98-
with:
99-
path: |
100-
~/.cargo/.crates.toml
101-
~/.cargo/.crates2.json
102-
~/.cargo/registry/index
103-
~/.cargo/registry/cache
104-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
87+
- name: Rust Cache
88+
uses: Swatinem/[email protected]
10589
- name: install tiup
10690
run: curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
10791
- name: start tiup playground
108-
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 &
92+
run: |
93+
~/.tiup/bin/tiup install tikv:nightly pd:nightly
94+
~/.tiup/bin/tiup playground nightly --mode tikv-slim --kv 3 --without-monitor --kv.config config/tikv.toml --pd.config config/pd.toml &
95+
while :; do
96+
echo "waiting cluster to be ready"
97+
[[ "$(curl -I http://127.0.0.1:2379/pd/api/v1/regions 2>/dev/null | head -n 1 | cut -d$' ' -f2)" -ne "405" ]] || break
98+
sleep 1
99+
done
109100
- name: integration test
110101
run: MULTI_REGION=1 make integration-test

config/tikv.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ region-split-keys = 7
44
batch-split-limit = 100
55

66
[raftstore]
7-
region-split-check-diff = "0KB"
7+
region-split-check-diff = "1B"
88
pd-heartbeat-tick-interval = "2s"
99
pd-store-heartbeat-tick-interval = "5s"
1010
split-region-check-tick-interval = "1s"

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{path::PathBuf, time::Duration};
88
///
99
/// See also [`TransactionOptions`](crate::TransactionOptions) which provides more ways to configure
1010
/// requests.
11-
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
11+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
1212
#[serde(default)]
1313
#[serde(rename_all = "kebab-case")]
1414
pub struct Config {

src/pd/client.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub trait PdClient: Send + Sync + 'static {
7474
fn group_keys_by_region<K, K2>(
7575
self: Arc<Self>,
7676
keys: impl Iterator<Item = K> + Send + Sync + 'static,
77-
) -> BoxStream<'static, Result<(RegionId, Vec<K2>)>>
77+
) -> BoxStream<'static, Result<(RegionWithLeader, Vec<K2>)>>
7878
where
7979
K: AsRef<Key> + Into<K2> + Send + Sync + 'static,
8080
K2: Send + Sync + 'static,
@@ -85,15 +85,14 @@ pub trait PdClient: Send + Sync + 'static {
8585
async move {
8686
if let Some(key) = keys.next() {
8787
let region = this.region_for_key(key.as_ref()).await?;
88-
let id = region.id();
8988
let mut grouped = vec![key.into()];
9089
while let Some(key) = keys.peek() {
9190
if !region.contains(key.as_ref()) {
9291
break;
9392
}
9493
grouped.push(keys.next().unwrap().into());
9594
}
96-
Ok(Some((keys, (id, grouped))))
95+
Ok(Some((keys, (region, grouped))))
9796
} else {
9897
Ok(None)
9998
}
@@ -137,7 +136,7 @@ pub trait PdClient: Send + Sync + 'static {
137136
fn group_ranges_by_region(
138137
self: Arc<Self>,
139138
mut ranges: Vec<kvrpcpb::KeyRange>,
140-
) -> BoxStream<'static, Result<(RegionId, Vec<kvrpcpb::KeyRange>)>> {
139+
) -> BoxStream<'static, Result<(RegionWithLeader, Vec<kvrpcpb::KeyRange>)>> {
141140
ranges.reverse();
142141
stream_fn(Some(ranges), move |ranges| {
143142
let this = self.clone();
@@ -151,7 +150,6 @@ pub trait PdClient: Send + Sync + 'static {
151150
let start_key: Key = range.start_key.clone().into();
152151
let end_key: Key = range.end_key.clone().into();
153152
let region = this.region_for_key(&start_key).await?;
154-
let id = region.id();
155153
let region_start = region.start_key();
156154
let region_end = region.end_key();
157155
let mut grouped = vec![];
@@ -164,7 +162,7 @@ pub trait PdClient: Send + Sync + 'static {
164162
start_key: region_end.into(),
165163
end_key: end_key.into(),
166164
});
167-
return Ok(Some((Some(ranges), (id, grouped))));
165+
return Ok(Some((Some(ranges), (region, grouped))));
168166
}
169167
grouped.push(range);
170168

@@ -184,11 +182,11 @@ pub trait PdClient: Send + Sync + 'static {
184182
start_key: region_end.into(),
185183
end_key: end_key.into(),
186184
});
187-
return Ok(Some((Some(ranges), (id, grouped))));
185+
return Ok(Some((Some(ranges), (region, grouped))));
188186
}
189187
grouped.push(range);
190188
}
191-
Ok(Some((Some(ranges), (id, grouped))))
189+
Ok(Some((Some(ranges), (region, grouped))))
192190
} else {
193191
Ok(None)
194192
}
@@ -445,7 +443,7 @@ pub mod test {
445443
let ranges3 = stream.next().unwrap().unwrap();
446444
let ranges4 = stream.next().unwrap().unwrap();
447445

448-
assert_eq!(ranges1.0, 1);
446+
assert_eq!(ranges1.0.id(), 1);
449447
assert_eq!(
450448
ranges1.1,
451449
vec![
@@ -459,23 +457,23 @@ pub mod test {
459457
},
460458
]
461459
);
462-
assert_eq!(ranges2.0, 2);
460+
assert_eq!(ranges2.0.id(), 2);
463461
assert_eq!(
464462
ranges2.1,
465463
vec![kvrpcpb::KeyRange {
466464
start_key: k_split.clone(),
467465
end_key: k3,
468466
}]
469467
);
470-
assert_eq!(ranges3.0, 1);
468+
assert_eq!(ranges3.0.id(), 1);
471469
assert_eq!(
472470
ranges3.1,
473471
vec![kvrpcpb::KeyRange {
474472
start_key: k2,
475473
end_key: k_split.clone(),
476474
}]
477475
);
478-
assert_eq!(ranges4.0, 2);
476+
assert_eq!(ranges4.0.id(), 2);
479477
assert_eq!(
480478
ranges4.1,
481479
vec![kvrpcpb::KeyRange {

0 commit comments

Comments
 (0)