Giter VIP home page Giter VIP logo

chiselstore's Introduction

ChiselStore

Rust MIT licensed

ChiselStore is an embeddable, distributed SQLite for Rust, powered by Little Raft.

SQLite is a fast and compact relational database management system, but it is limited to single-node configurations. ChiselStore extends SQLite to run on a cluster of machines with the Raft consensus algorithm. With ChiselStore, you get the benefits of easy-to-use, embeddable SQLite but with Raft's high availability and fault tolerance.

For more information, check out the following blog post.

Features

  • SQLite with Raft's high availability and fault tolerance
  • Strong consistency with optional relaxed reads
  • Embeddable Rust library

Roadmap

  • Efficient node restarts (with Raft snapshots)
  • Dynamic cluster membership (with Raft joint consensus)
  • Support executing non-deterministic SQL functions

Getting Started

See the example server of how to use the ChiselStore library.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in ChiselStore by you, shall be licensed as MIT, without any additional terms or conditions.

chiselstore's People

Contributors

glommer avatar kilerd avatar penberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chiselstore's Issues

Example server fails to start

When attempting to start the example server, I trip over:

penberg@vonneumann chiselstore % cargo run --example gouged -- --id 1 --peers 2 3
    Updating crates.io index
   Compiling event-listener v2.5.3
   Compiling chiselstore v0.1.0 (/Users/penberg/src/chiselstrike/chiselstore/core)
   Compiling async-mutex v1.4.0
    Finished dev [unoptimized + debuginfo] target(s) in 6.63s
     Running `target/debug/examples/gouged --id 1 --peers 2 3`
RPC listening to 127.0.0.1:50001 ...
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: tonic::transport::Error(Transport, hyper::Error(Connect, ConnectError("tcp connect error", Os { code: 61, kind: ConnectionRefused, message: "Connection refused" })))', core/src/rpc.rs:55:52
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: tonic::transport::Error(Transport, hyper::Error(Connect, ConnectError("tcp connect error", Os { code: 61, kind: ConnectionRefused, message: "Connection refused" })))', core/src/rpc.rs:55:52

I bisected the problem to 75ec0c7

Connection pool for RPC

Currently, RPCs establish a new connection for every invocation. Let's use a connection pool to make this faster.

Snapshot support

Currently, the replicated Raft log grows unbounded. First, we need to add Raft snapshot support to Little Raft, which allows truncating the log. We then need to add snapshot support to ChiselStore with, for example, SQLite online backups: https://www.sqlite.org/backup.html. IOW, normal reads and writes could go to an in-memory database, and at snapshot time, an on-disk backup is created. When a node is restarted, the on-disk backup could be read to an in-memory database.

Executing non-deterministic SQL functions

Non-deterministic SQL function such as date() and random() must be evaluated only once. We can do this by evaluating the functions only on leader and replicate the evaluated values to followers.

Can't build the project or even run the example

cargo build
    Updating crates.io index
    Updating git repository `https://github.com/chiselstrike/little-raft.git`
   Compiling chiselstore v0.1.0 (/Users/cscetbon/src/git/chiselstore/core)
error: failed to run custom build command for `chiselstore v0.1.0 (/Users/cscetbon/src/git/chiselstore/core)`

Caused by:
  process didn't exit successfully: `/Users/cscetbon/src/git/chiselstore/target/debug/build/chiselstore-8207c42d14ef8b10/build-script-build` (exit status: 1)
  --- stderr
  error running rustfmt: Os { code: 2, kind: NotFound, message: "No such file or directory" }

Improve clippy lints

@glommer suggests:

Pekka, please add a variation of #![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)] to the top-level lib file so we make sure that all public interfaces have Debug, documentation, etc (likely you will want to enforce 2021 idioms)

Make node IP addresses configurable for `gouged`

Currently gouged assumes that all nodes are running on local machine and uses a mapping between nodes and ports. Make the peer IP addresses configurable to make testing with multiple machines easier.

SQLite transaction dead-lock

We currently let SQL transaction commands to replicate, which can result in a dead-lock.

For example, if a writer issues a BEGIN TRANSACTION command, but dies after it has replicated, the cluster is in a situation where all nodes have an active transaction, but there's now writer to commit or roll back.

Optimize reads

Currently, ChiselStore performs reads using the Raft consensus protocol -- just like writes -- which provides strong consistency. However, strong consistency also makes reads pretty expensive. One way to optimize reads is to provide a "local read" option, which performs reads on any node. The "local read" option relaxes the consistency model by allowing stale reads in exchange for higher performance.

Enforce exactly-once semantics

If a leader crashes after applying a command to the state machine, but before responding to a client, the client will re-try the command, which breaks exactly-once semantics. One way to fix this is to make the client include an ID for every command. A leader can then check for the ID in its log before applying a command to its state machine to detect stale commands.

Use in-memory SQLite

We currently use file-backed SQLite databases because the basic in-memory SQLite does not seem to support concurrent reads:

75ec0c7

Let's look at ways to turn on in-memory again. For example, the "memdb" VFS should support concurrent reads.

I/O errors should crash the process

If we have an I/O error, we must not resume completion, but instead crash the process so that node with partial results does not continue in the same Raft cluster.

Read-your-writes consistency guarantee for relaxed reads

With relaxed reads, there's currently no guarantee on read-your-write consistency. This is because a write will be acknowledged when the write is applied to the state machine of the leader, but not on the local replica.

Example:

  • A follower node F receives a write request, which is delegated to node L, which is the leader.
  • The write is replicated to the logs of all nodes (but not necessarily applied).
  • The write is applied to the state machine of L.
  • L acknowledges the write to F and F acknowledges the write to the client.
  • A relaxed read request arrives on node F, which does not yet have the write applied to its state machine, violating read-your-writes consistency.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.