Skip to content

Commit b01ffcc

Browse files
authored
feat(query): try support dump running async task stack (#10830)
* refactor(query): add dump * refactor(query): add framed for sql * refactor(query): add framed for sharing-endpoint * refactor(query): add framed for storages * refactor(query): add framed for users * refactor(query): add framed for services * refactor(query): add framed for spawn * refactor(query): try fix test failure * refactor(query): try fix test failure * refactor(query): add tasks sort * refactor(query): add framed for storage
1 parent 671d60f commit b01ffcc

File tree

382 files changed

+1651
-440
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

382 files changed

+1651
-440
lines changed

Cargo.lock

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ reqwest = { version = "0.11", default-features = false, features = [
145145
# runtime
146146
tokio = { version = "1.26.0", features = ["full"] }
147147

148+
# backtrace
149+
async-backtrace = "0.2.2"
150+
148151
[profile.release]
149152
debug = 1
150153
lto = "thin"

src/binaries/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ sharing-endpoint = { path = "../query/sharing-endpoint" }
6060
# Crates.io dependencies
6161
anyerror = { workspace = true }
6262
anyhow = { workspace = true }
63+
async-backtrace = { workspace = true }
6364
clap = { workspace = true }
6465
comfy-table = "6.1.3"
6566
limits-rs = "0.2.0"

src/binaries/query/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn main() {
5454
std::process::exit(cause.code() as i32);
5555
}
5656
Ok(rt) => {
57-
if let Err(cause) = rt.block_on(main_entrypoint()) {
57+
if let Err(cause) = rt.block_on(async_backtrace::location!().frame(main_entrypoint())) {
5858
eprintln!("Databend Query start failure, cause: {:?}", cause);
5959
std::process::exit(cause.code() as i32);
6060
}

src/common/base/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ common-exception = { path = "../exception" }
2626
# Github dependencies
2727

2828
# Crates.io dependencies
29+
async-backtrace = "0.2.2"
2930
async-channel = "1.7.1"
3031
async-trait = "0.1.57"
3132
bytesize = "1.1.0"

src/common/base/src/runtime/runtime.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ impl Runtime {
155155
runtime_builder.thread_name(thread_name);
156156
}
157157
}
158+
159+
runtime_builder.thread_stack_size(5 * 1024 * 1024);
158160
}
159161

160162
Self::create(None, mem_stat, &mut runtime_builder)
@@ -179,6 +181,8 @@ impl Runtime {
179181
thread_name = Some(cur_thread_name.to_string());
180182
}
181183
}
184+
185+
runtime_builder.thread_stack_size(5 * 1024 * 1024);
182186
}
183187

184188
if let Some(thread_name) = &thread_name {
@@ -255,10 +259,12 @@ impl Runtime {
255259
let permit = semaphore.acquire_owned().await.map_err(|e| {
256260
ErrorCode::Internal(format!("semaphore closed, acquire permit failure. {}", e))
257261
})?;
258-
let handler = self.handle.spawn(async move {
259-
// take the ownership of the permit, (implicitly) drop it when task is done
260-
fut(permit).await
261-
});
262+
let handler = self
263+
.handle
264+
.spawn(async_backtrace::location!().frame(async move {
265+
// take the ownership of the permit, (implicitly) drop it when task is done
266+
fut(permit).await
267+
}));
262268
handlers.push(handler)
263269
}
264270

@@ -273,7 +279,7 @@ impl TrySpawn for Runtime {
273279
T: Future + Send + 'static,
274280
T::Output: Send + 'static,
275281
{
276-
Ok(self.handle.spawn(task))
282+
Ok(self.handle.spawn(async_backtrace::location!().frame(task)))
277283
}
278284
}
279285

src/common/base/src/runtime/runtime_tracker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ mod tests {
670670
.unwrap();
671671

672672
rt.block_on(async {
673-
let h = tokio::spawn(f);
673+
let h = tokio::spawn(async_backtrace::location!().frame(f));
674674
let res = h.await;
675675
assert!(res.is_err(), "panicked");
676676
});

src/common/base/src/runtime/thread.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ impl Thread {
6363
name = Some(thread_name.to_string());
6464
}
6565
}
66+
67+
thread_builder = thread_builder.stack_size(5 * 1024 * 1024);
6668
}
6769

6870
let mut mem_stat_name = String::from("UnnamedThread");

src/common/base/tests/it/runtime.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ async fn test_shutdown_long_run_runtime() -> Result<()> {
8585
}
8686

8787
static START_TIME: Lazy<Instant> = Lazy::new(Instant::now);
88+
8889
// println can more clearly know if they are parallel
8990
async fn mock_get_page(i: usize) -> Vec<usize> {
9091
let millis = Uniform::from(0..10).sample(&mut rand::thread_rng());

src/common/http/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ common-exception = { path = "../exception" }
2424

2525
# Crates.io dependencies
2626
anyerror = { workspace = true }
27+
async-backtrace = { workspace = true }
2728
futures = "0.3.24"
2829
poem = { version = "1", features = ["rustls"] }
2930
serde = { workspace = true }

0 commit comments

Comments
 (0)