# Does \`fdb\_future\_set\_callback\` guarantee exactly-once execution?

**URL:** <https://forums.foundationdb.org/t/does-fdb-future-set-callback-guarantee-exactly-once-execution/1498>\
**Category:** Using FoundationDB\
**Created:** [June 28, 2019, 5:08pm UTC](https://forums.foundationdb.org/t/does-fdb-future-set-callback-guarantee-exactly-once-execution/1498 "2019-06-28T17:08:44Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ajbeamon](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ajbeamon/32/13_2.png) [@ajbeamon](https://forums.foundationdb.org/u/ajbeamon)\
**Post date:** [June 28, 2019, 7:58pm UTC](https://forums.foundationdb.org/t/does-fdb-future-set-callback-guarantee-exactly-once-execution/1498/3 "2019-06-28T19:58:22Z")

</div>

It’s true that we can’t guarantee that an operation will complete (and thus call the callback), but I think it’s the case that canceling or destroying the future will cause the callback to complete with an error. Thus you could guarantee that the callback would fire if you canceled or destroyed the future at some point.

Something else that we rely on in some of our bindings is that destroying a transaction will terminate all the futures associated with the transaction. For example, in Java we have explicit APIs for cleaning up native objects (i.e. by calling `close` on their Java wrapper objects). We don’t require this for future types, though, and the only way for them to be cleaned up is by them being completed. We depend on the user destroying the transaction to clean up any stray ones that haven’t yet fired.

> [@markus.pilman](#):
>
> From 6.2 on you can set this on the database level

This option is actually available in 6.1, see for example [Python API — FoundationDB 7.1](https://apple.github.io/foundationdb/api-python.html#database-options).

> [@markus.pilman](#):
>
> There is a very strong argument for setting this option by default to something that makes sense (5-10s maybe?) but this makes testing harder (if I remember the discussion correctly - otherwise I believe @ajbeamon might be able to explain this better than I can).

I think if you choose a default that makes sense for your use-case and test it, it should be fine. My main concerns were around what happens when we’ve chosen the default for you and you don’t test what happens when you encounter it (which is also relevant when the default is no timeout, as it currently is).

---

_[View the full topic](https://forums.foundationdb.org/t/does-fdb-future-set-callback-guarantee-exactly-once-execution/1498)._
