# Fdb-zk: rough cut of Zookeeper API layer

**URL:** <https://forums.foundationdb.org/t/fdb-zk-rough-cut-of-zookeeper-api-layer/1278>\
**Category:** Using FoundationDB\
**Created:** [April 3, 2019, 2:54am UTC](https://forums.foundationdb.org/t/fdb-zk-rough-cut-of-zookeeper-api-layer/1278 "2019-04-03T02:54:03Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![alexmiller](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/alexmiller/32/326_2.png) [@alexmiller](https://forums.foundationdb.org/u/alexmiller)\
**Post date:** [April 4, 2019, 1:06am UTC](https://forums.foundationdb.org/t/fdb-zk-rough-cut-of-zookeeper-api-layer/1278/5 "2019-04-04T01:06:33Z")

</div>

> [@pH14](#):
>
> That’s an interesting idea – it seems like it’d have to be coupled with read-repairs, in the case that a client hasn’t yet been elected. Any preferred janky leader election techniques?

You can have your clients check `leaderKey` for an (ID, versionstamp), and consider that process to be the leader if its versionstamp is within 10,000,000 of your read version. Write {ID, versionstamp} to the database if the key is empty or the versionstamp was too old. Heartbeat `leaderKey`, and also watch it from the leader so that it is informed if it loses leadership. You’ll get re-elections every time FDB has a recovery, and you could have more than one leader for a short time, but that seems fine in your use case.

> [@pH14](#):
>
> I haven’t looked too deeply into the Record Layer – how does it handle a task like generating a new secondary index on existing data? That seems like a related concern.

See [Best way to add an index on already-existing data? - #2 by alloc](https://forums.foundationdb.org/t/best-way-to-add-an-index-on-already-existing-data/97/2), which is Alec answering basically that.

---

_[View the full topic](https://forums.foundationdb.org/t/fdb-zk-rough-cut-of-zookeeper-api-layer/1278)._
