Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrent write to the db crashes #1505

Open
akiradeveloper opened this issue Jun 2, 2024 · 0 comments
Open

Concurrent write to the db crashes #1505

akiradeveloper opened this issue Jun 2, 2024 · 0 comments
Labels

Comments

@akiradeveloper
Copy link

I run this program with n_lanes=16 and datalen=10000 and it crashed. I am benchmarking sled in my project.

use clap::Parser;
use std::time::Duration;

#[derive(Parser)]
struct Opts {
    n_lanes: usize,
    datalen: usize,
    #[clap(long, default_value = "5")]
    du: u16,
}
fn main() {
    let opts = Opts::parse();
    let (collector, q) = stats::Collector::new();

    std::fs::remove_dir_all("db").ok();
    std::fs::create_dir("db").unwrap();
    let db: sled::Db = sled::Config::new()
        .path("db")
        .flush_every_ms(Some(100))
        .open()
        .unwrap();

    for lane_id in 0..opts.n_lanes {
        let tree = db.open_tree(format!("id={lane_id}")).unwrap();
        let mut reporter = stats::Reporter::new(q.clone());
        std::thread::spawn(move || {
            for i in 0.. {
                let k = i.to_string();
                let v = stats::randbytes(opts.datalen);

                reporter.start();
                tree.insert(&k, v).unwrap();
                reporter.stop(opts.datalen);
            }
        });
    }

    let du = Duration::from_secs(opts.du as u64);
    std::thread::sleep(du);
    eprintln!("{}", collector.show(du));
}
  1. expected result: I should complete
  2. actual result: crashed
  3. sled version: 1.0.0-alpha.121
  4. rustc version: 1.78
  5. operating system: Ubuntu 22.04
  6. minimal code sample that helps to reproduce the issue: shown above
  7. logs, panic messages, stack traces: https://github.com/akiradeveloper/kvs-perf-evaluation/actions/runs/9336280337/job/25696639010
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant