crclark / foundationdb-haskell

Haskell FFI bindings to the FoundationDB C API
https://crclark.github.io/foundationdb-haskell/
BSD 3-Clause "New" or "Revised" License
36 stars 5 forks source link

Add FoundationDB 7.1 Support #52

Closed xnomagichash closed 1 year ago

xnomagichash commented 2 years ago

FoundationDB 7.1 was released in April. According to the release notes for 7.1 and 7.0:

There are several new features, but probably no breaking changes. The new features are:

Get range and flat map

C: Added fdb_transaction_get_range_and_flat_map function to support running queries based on another query in one request. (PR #5609)

Reboot worker

C: Added a function, fdb_database_reboot_worker, to reboot or suspend the specified process. (PR #4094)

Force recovery

C: Added a function, fdb_database_force_recovery_with_data_loss, to force the database to recover into the given datacenter. (PR #4220)

Create snapshot

C: Added a function, fdb_database_create_snapshot, to create a snapshot of the database. (PR #4241)

Get main thread busyness

C: Added fdb_database_get_main_thread_busyness function to report how busy a client’s main thread is. (PR #4504)

I'm not sure how many of these actually are even worth exposing in the high level interface. Maybe only fdb_transaction_get_range_and_flat_map.

crclark commented 2 years ago

Wow, I didn't see a 7.1 release announcement on the blog. Thanks for the heads-up!

I will start working on support over the next few weekends.

Since this library doesn't currently expose administrative functions, I will focus on fdb_transaction_get_range_and_flat_map.

crclark commented 2 years ago

It looks like there is also new functionality for multi-tenancy. I'll look into adding support for that.

crclark commented 2 years ago

fdb_database_get_main_thread_busyness also looks handy.

crclark commented 2 years ago

Some notes to myself as I start implementing the secondary index helper...

Can't find any docs for fdb_transaction_get_mapped_range and fdb_future_get_mappedkeyvalue_array. The returned struct is a bit complex.

This PR introduced the current API. Here is a unit test in the PR.

This older PR introduced a first version of this API and has some other details. Here is a unit test in that PR.

crclark commented 2 years ago

https://forums.foundationdb.org/t/getmappedrange-and-recordlayer/3263

https://forums.foundationdb.org/t/everything-about-getmappedrange/3280

https://github.com/apple/foundationdb/wiki/Everything-about-GetMappedRange

Rust library's docs for this function, can probably learn more by reading the code. https://docs.rs/foundationdb/latest/foundationdb/struct.Transaction.html#method.get_mapped_range

crclark commented 2 years ago

Test from the Rust bindings gives a clear usage example: https://github.com/foundationdb-rs/foundationdb-rs/pull/61/files#diff-973f2b62dd7045ff9b764489e9e32ac3a0a3544a58ff96baeec4ce04896b3979

crclark commented 2 years ago

@xnomagichash I just merged the most interesting new feature, mapped range support.

xnomagichash commented 2 years ago

Thanks! I can confirm it works and after some (a lot) trial and error was also able to get it working on an M1 macbook with foundationdb 7.1.18.