Skip to content

Commit 2595e6f

Browse files
committed
debug log
Signed-off-by: Ping Yu <[email protected]>
1 parent 8883953 commit 2595e6f

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
CARGO_INCREMENTAL: 0
6262
NEXTEST_PROFILE: ci
6363
TIKV_VERSION: v8.5.1
64+
RUST_LOG: debug
6465
runs-on: ubuntu-latest
6566
steps:
6667
- uses: actions/checkout@v4

src/request/plan.rs

+20-4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ where
116116
preserve_region_results: bool,
117117
) -> Result<<Self as Plan>::Result> {
118118
let shards = current_plan.shards(&pd_client).collect::<Vec<_>>().await;
119+
debug!("single_plan_handler, shards: {}", shards.len());
119120
let mut handles = Vec::new();
120121
for shard in shards {
121122
let handle = tokio::spawn(Self::single_shard_handler(
@@ -158,11 +159,16 @@ where
158159
permits: Arc<Semaphore>,
159160
preserve_region_results: bool,
160161
) -> Result<<Self as Plan>::Result> {
162+
debug!("single_shard_handler");
161163
let region_store = match shard.and_then(|(shard, region_store)| {
162164
plan.apply_shard(shard, &region_store).map(|_| region_store)
163165
}) {
164166
Ok(region_store) => region_store,
165167
Err(Error::LeaderNotFound { region }) => {
168+
debug!(
169+
"single_shard_handler::sharding: leader not found: {:?}",
170+
region
171+
);
166172
return Self::handle_other_error(
167173
pd_client,
168174
plan,
@@ -173,9 +179,12 @@ where
173179
preserve_region_results,
174180
Error::LeaderNotFound { region },
175181
)
176-
.await
182+
.await;
183+
}
184+
Err(err) => {
185+
debug!("single_shard_handler::sharding, error: {:?}", err);
186+
return Err(err);
177187
}
178-
Err(err) => return Err(err),
179188
};
180189

181190
// limit concurrent requests
@@ -186,6 +195,7 @@ where
186195
let mut resp = match res {
187196
Ok(resp) => resp,
188197
Err(e) if is_grpc_error(&e) => {
198+
debug!("single_shard_handler:execute: grpc error: {:?}", e);
189199
return Self::handle_other_error(
190200
pd_client,
191201
plan,
@@ -198,12 +208,17 @@ where
198208
)
199209
.await;
200210
}
201-
Err(e) => return Err(e),
211+
Err(e) => {
212+
debug!("single_shard_handler:execute: error: {:?}", e);
213+
return Err(e);
214+
}
202215
};
203216

204217
if let Some(e) = resp.key_errors() {
218+
debug!("single_shard_handler:execute: key errors: {:?}", e);
205219
Ok(vec![Err(Error::MultipleKeyErrors(e))])
206220
} else if let Some(e) = resp.region_error() {
221+
debug!("single_shard_handler:execute: region error: {:?}", e);
207222
match backoff.next_delay_duration() {
208223
Some(duration) => {
209224
let region_error_resolved =
@@ -239,7 +254,7 @@ where
239254
preserve_region_results: bool,
240255
e: Error,
241256
) -> Result<<Self as Plan>::Result> {
242-
debug!("handle grpc error: {:?}", e);
257+
debug!("handle_other_error: {:?}", e);
243258
pd_client.invalidate_region_cache(region).await;
244259
if is_grpc_error(&e) {
245260
if let Some(store_id) = store {
@@ -272,6 +287,7 @@ pub(crate) async fn handle_region_error<PdC: PdClient>(
272287
e: errorpb::Error,
273288
region_store: RegionStore,
274289
) -> Result<bool> {
290+
debug!("handle_region_error: {:?}", e);
275291
let ver_id = region_store.region_with_leader.ver_id();
276292
let store_id = region_store.region_with_leader.get_store_id();
277293
if let Some(not_leader) = e.not_leader {

tests/common/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ pub async fn clear_tikv() {
4646
// To test with multiple regions, prewrite some data. Tests that hope to test
4747
// with multiple regions should use keys in the corresponding ranges.
4848
pub async fn init() -> Result<()> {
49+
let _ = env_logger::try_init();
50+
4951
if env::var(ENV_ENABLE_MULIT_REGION).is_ok() {
5052
// 1000 keys: 0..1000
5153
let keys_1 = std::iter::successors(Some(0u32), |x| Some(x + 1))

0 commit comments

Comments
 (0)