Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clean FoundationDB?

Tags:

foundationdb

Is there any fast way to remove all data from the local database? Like SQL 'drop database'?

I was looking through the documentation but haven't found anythig interesting yet.

like image 275
irytek102 Avatar asked Jan 28 '14 21:01

irytek102


2 Answers

The "CLI" way

Using the provided fdbcli interface, you can clear all the keys in the database using a single clearrange command, like this:

fdb> writemode on
fdb> clearrange "" \xFF
Committed (68666816293119)

Be warned that it executes instantly and that there is no undo possible!

Also, any application still connected to the database may continue reading/writing data using cached directory subspace prefixes, which may introduce data corruption! You should make sure to only use this method when nothing is actively using the cluster.

This method requires that your cluster be in a working state, and it will not immediately reclaim the space used on disk, and also will not reset the cluster's read version.

The "hard" way

If you have a single-node cluster, you can stop the fdb service, remove all files in its data_dir folder, restart the service, and then using fdbcli, execute the configure new single ssd command.

This will reclaim the disk space used previously, and reset everything back to the post-install state.

like image 196
Christophe Chevalier Avatar answered Nov 11 '22 01:11

Christophe Chevalier


You can do this by clearing the entire range of keys.

In Python, it looks like this:

Database.clear_range('', '\xFF')

Where '' is the default slice begin, and '\xFF' is the default slice end, according to the clear_range documentation.

You can find the more information on clear_range for the API you're using in the documentation.

like image 22
jrullmann Avatar answered Nov 11 '22 02:11

jrullmann