# Protect database from corruption

**URL:** <https://forums.foundationdb.org/t/protect-database-from-corruption/1478>\
**Category:** Using FoundationDB\
**Created:** [June 20, 2019, 9:18pm UTC](https://forums.foundationdb.org/t/protect-database-from-corruption/1478 "2019-06-20T21:18:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ex3ndr](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ex3ndr/32/389_2.png) [@ex3ndr](https://forums.foundationdb.org/u/ex3ndr)\
**Post date:** [June 20, 2019, 9:18pm UTC](https://forums.foundationdb.org/t/protect-database-from-corruption/1478/1 "2019-06-20T21:18:03Z")

</div>

Since FoundationDB is essentially a one large key value store there is a huge risk of misconfiguration or just human error during building our own layers.

One of the most risky operations is range clear. Are there any best practices to avoid wiping all data (imagine just forgetting to pack prefix!). Right now i am building a library for nodejs for easier layer implementations and one of the goals is to provide safe way to do experiments. Until today we just didn’t have clearRange at all and it worked fine since other way of corrupting data is much more complicated (writing data to wrong keys is not that easy).

Does anyone have other ideas?

---

<div class="post-metadata">

**Author:** ![MMcM](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@MMcM](https://forums.foundationdb.org/u/MMcM)\
**Post date:** [June 20, 2019, 10:38pm UTC](https://forums.foundationdb.org/t/protect-database-from-corruption/1478/2 "2019-06-20T22:38:35Z")

</div>

Is it possible to just have the basic abstractions that mediate all operations discourage this?

Like,

- Something wrapping a transaction.
- Something wrapping a subspace and pointing to the above.

(The record layer calls these “context” and “store,” respectively.)

Nothing prevents you from clearing the whole database, but you have to “open the whole database” first. If you just open a smaller database, then that’s the widest you can go. Which doesn’t eliminate problems within that subspace, but does avoid “wiping all data.”

---

<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:** [June 20, 2019, 11:24pm UTC](https://forums.foundationdb.org/t/protect-database-from-corruption/1478/3 "2019-06-20T23:24:21Z")

</div>

See [#1419](https://github.com/apple/foundationdb/issues/1419) for why this is a hard feature to offer, as well.
