Skip to content

Commit

Permalink
tests: cache symbols ahead of time (tikv#10994)
Browse files Browse the repository at this point in the history
* tests: cache symbols ahead of time

TiKV uses backtrace to record suspicious problems in tests. But creating
a backtrace can take several seconds and lead to unexpected timeout for
cases.

This PR loads all symbols ahead of time to reduce the probability of
timeout. tikv-server binary also uses similar way to get around the
issue.

Signed-off-by: Jay Lee <[email protected]>

* fix format

Signed-off-by: Jay Lee <[email protected]>

Co-authored-by: qupeng <[email protected]>
Co-authored-by: Ti Chi Robot <[email protected]>
  • Loading branch information
3 people authored Sep 27, 2021
1 parent 00f4586 commit f9bbdbc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions components/test_raftstore/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ impl Drop for CallbackLeakDetector {
if self.called {
return;
}

debug!("before capture");
let bt = backtrace::Backtrace::new();
warn!("callback is dropped"; "backtrace" => ?bt);
}
Expand Down
1 change: 1 addition & 0 deletions components/test_util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ cloud-aws = [ "encryption_export/cloud-aws" ]
cloud-gcp = [ "encryption_export/cloud-gcp" ]

[dependencies]
backtrace = "0.3"
encryption_export = { path = "../encryption/export", default-features = false }
fail = "0.4"
grpcio = { version = "0.9", default-features = false, features = ["openssl-vendored"] }
Expand Down
10 changes: 9 additions & 1 deletion components/test_util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ mod runner;
mod security;

use rand::Rng;
use std::env;
use std::sync::atomic::{AtomicU16, Ordering};
use std::{env, thread};

pub use crate::encryption::*;
pub use crate::kv_generator::*;
Expand All @@ -27,6 +27,14 @@ pub use crate::runner::{
pub use crate::security::*;

pub fn setup_for_ci() {
// We use backtrace in tests to record suspicious problems. And loading backtrace
// the first time can take several seconds. Spawning a thread and load it ahead
// of time to avoid causing timeout.
thread::Builder::new()
.name(tikv_util::thd_name!("backtrace-loader"))
.spawn(::backtrace::Backtrace::new)
.unwrap();

if env::var("CI").is_ok() {
// HACK! Use `epollex` as the polling engine for gRPC when running CI tests on
// Linux and it hasn't been set before.
Expand Down

0 comments on commit f9bbdbc

Please sign in to comment.