1 of 46

From contributor

to main maintainer

of a Rust database driver

Pierre Zemb

@PierreZ

2 of 46

$ whoami

  • Pierre Zemb
  • Staff Engineer
    • Leading our serverless database offer
    • Mostly working around distributed systems
  • OSS maintainer
    • Mostly in Rust
  • Involved in local communities such as
  • Squash player

@PierreZ

3 of 46

$ whoami

  • Pierre Zemb
  • Staff Engineer
    • Leading our serverless database offer
    • Mostly working around distributed systems
  • OSS maintainer
    • Mostly in Rust
  • Involved in local communities such as
  • Squash player

@PierreZ

4 of 46

5 years ago…

  • I was curious towards a distributed system called FoundationDB
  • I was playing it with Java, and decided to test the driver in Rust and noticed that:
    • It was a community-based bindings
    • several features were missing
  • So, I decided to contribute to it!
    • Opened 3 Pull requests

@PierreZ

5 of 46

No response…

@PierreZ

6 of 46

Then, one day…

I received a mail from the former maintainer:

  • no longer employed by Clikengo since March and now only have contributor rights
  • the current president seems to ignore GitHub entirely
  • He can still publish the crates on crates.io
  • MIT/Apache 2.0 license also poses no legal concerns
  • We should move the main repository elsewhere

@PierreZ

7 of 46

@PierreZ

8 of 46

@PierreZ

9 of 46

Today

  • 16k lines of Rust
  • More than 5M downloads total
    • Around ~20k daily
  • New release every ~9 months
  • 30 contributors in total
    • 1 main contributor
  • Used by:
    • companies like Datadog, Clever Cloud, OVHcloud
      • Maybe Cloudflare, Tangia, SpiralDB, Molnett
    • projects like
      • Apache OpenDAL, SurrealDB,
      • mvstore, and other hobby-grade projects

@PierreZ

10 of 46

How do I maintain the binding?

@PierreZ

11 of 46

How do I maintain the binding?

How I make sure that the bindings

is working properly?

🙈🙉🙊

@PierreZ

12 of 46

Rust, or the curse of FFI

  • The Rust code is not a full database crate, it is communicating with a C-library that is handling everything
    • The rust code is only a wrapper around some C code
  • The good news is that the library is handling all the complicated stuff for us!
  • The bad news is that you need to connect Rust and C code!

foundationdb-rs

Written in Rust

libfdb

Written in C

FoundationDB

FoundationDB

FoundationDB

@PierreZ

13 of 46

FFI and Bindgen

  • so you need to:
    • Generate the FFI(Foreign function interface) using bindgen
    • Wrap the unsafe function
    • test a lot!

foundationdb-rs

Written in Rust

libfdb

Written in C

@PierreZ

14 of 46

Dev experience

@PierreZ

15 of 46

We need a lot of CI

  • We need to run tests on:
    • On multiple OS(Ubuntu, macOS)
    • On multiple FDB's versions(From FDB 6.1 to 7.3)
    • On multiple Rust compiler version(MSRV, stable, beta, nightly)
      • Nightly is super useful to find code that will not compile in the future!

@PierreZ

16 of 46

Testing is hard

  • We still need to write a lot of tests 😓
    • Tests hardly scale with features cardinality
  • We need to generate workloads / scenarios ⚙️

@PierreZ

17 of 46

The BindingTester

  • official tool to ensures language bindings interact correctly with FoundationDB
    1. Tests transactions, atomic ops, error handling, tuple encoding
  • Verifies uniform behavior across bindings
  • Runs seeded generated tests

@PierreZ

18 of 46

How does it works?

@PierreZ

19 of 46

How does it works?

@PierreZ

20 of 46

How does it works?

@PierreZ

21 of 46

How does it works?

@PierreZ

22 of 46

Benefits of the BindingTester

  • Running the bindingTester has been key to maintain the bindings
    • Find the unknowns bugs
    • The feedback loop is great, it finds bugs during dev
  • We are running it on:
    • scheduled CI
      • every hour thousands of tests
        • around 219 days of continuous testing each month
    • major PRs
      • Enforce 1k successful runs
  • Official bindings runs more than 100k bindingtester runs every night

@PierreZ

23 of 46

Binding’s safety

libfdb

(tested by Apple)

@PierreZ

24 of 46

Binding’s safety

fdb-rs

(tested with bindingTester)

libfdb

(tested by Apple)

@PierreZ

25 of 46

Binding’s safety

user’s code

How can we test this part???

fdb-rs

(tested with bindingTester)

libfdb

(tested by Apple)

@PierreZ

26 of 46

FoundationDB simulation framework

  • Before developing FoundationDB, they developed a deterministic simulation framework
    • The goal is to find bugs during development rather than the real world.
  • Simulates and inject failures into:
    • I/O: Network and Disk,
    • Time,
    • Cluster topology,
  • In a deterministic way
    • perfect repeatability

@PierreZ

27 of 46

@PierreZ

28 of 46

What is trying to achieve

@PierreZ

29 of 46

Introduce random network partitions

@PierreZ

30 of 46

Reboot up to 10 machines, keep at least 3 running

@PierreZ

31 of 46

@PierreZ

32 of 46

Will happen concurrently

@PierreZ

33 of 46

@PierreZ

34 of 46

@PierreZ

35 of 46

FDB and Rust

🦀

@PierreZ

36 of 46

FDB and Rust

🦀

@PierreZ

37 of 46

The workload trait

@PierreZ

38 of 46

Open-sourced

@PierreZ

39 of 46

And helping the community

@PierreZ

40 of 46

Binding’s safety

libfdb

(tested by Apple)

@PierreZ

41 of 46

Binding’s safety

fdb-rs

(tested with bindingTester)

libfdb

(tested by Apple)

@PierreZ

42 of 46

Binding’s safety

user’s code

(tested with the simulation)

fdb-rs

(tested with bindingTester)

libfdb

(tested by Apple)

@PierreZ

43 of 46

We are hiring 😉

@PierreZ

44 of 46

Automating things around Github

  • I cannot invest time every weeks to work on the crate, so I automated a lot of things
    • CI with Github Actions
      • On PR
      • On a schedule
    • bump dependencies with dependabot
    • The release process with Release-plz
      • Generate CHANGELOGs
      • git tags
      • github releases
      • publish to crates.io

@PierreZ

45 of 46

The good and the bad

  • I’m really happy to:
    • maintain the crate that is used
    • have included more safety and security
  • learned A LOT
  • Met people online and chat with them
  • I had a good codebase to work with from former maintainers
  • Managed to include work-time to maintain the library
  • I waited too long to automate some stuff
  • Some things are still missing:
    • guide, documentations, tutorials…
    • More maintainers
      • To have more reviews
    • More feedbacks from production

@PierreZ

46 of 46

Thanks!

Do you have any questions?

@PierreZ