# Indefinite blocking of fdb\_future\_block\_until\_ready even though DB is available

**URL:** <https://forums.foundationdb.org/t/indefinite-blocking-of-fdb-future-block-until-ready-even-though-db-is-available/1323>\
**Category:** Using FoundationDB\
**Tags:** bindings\
**Created:** [April 22, 2019, 12:11pm UTC](https://forums.foundationdb.org/t/indefinite-blocking-of-fdb-future-block-until-ready-even-though-db-is-available/1323 "2019-04-22T12:11:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sakthivelpvs](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@sakthivelpvs](https://forums.foundationdb.org/u/sakthivelpvs)\
**Post date:** [April 22, 2019, 12:11pm UTC](https://forums.foundationdb.org/t/indefinite-blocking-of-fdb-future-block-until-ready-even-though-db-is-available/1323/1 "2019-04-22T12:11:57Z")

</div>

The DB is available and able to retrieve data using fdbcli and the C client (client-1) written by also working for more than a week. Today’ I have tried to run the same client code without any change, but it was blocked by “fdb\_future\_block\_until\_ready” API call. It is not returning.

I’m able to connect and get db data from another client (client-2), which is similar to client-1 code. client-2 will write the data first and fetch the range of data after committing. But, client-1 code will try to fetch the range of data alone.

Here attaching piece of my code,

> #define FDB\_API\_VERSION 600  
> FDBDatabase \*db;  
> void db\_check\_error(fdb\_error\_t errorNum)  
> {  
> if(errorNum) {  
> fprintf(stderr, “Error (%d): %s\n”, errorNum, fdb\_get\_error(errorNum)); exit(errorNum);  
> }  
> }
> 
> void db\_run\_network()  
> {  
> db\_check\_error(fdb\_run\_network());  
> }
> 
> void wait\_and\_check\_error(FDBFuture \*future)  
> {  
> db\_check\_error(fdb\_future\_block\_until\_ready(future));  
> if(fdb\_future\_get\_error(future))  
> {  
> db\_check\_error(fdb\_future\_get\_error(future));  
> }  
> }
> 
> void db\_retrieve\_data()  
> {  
> const FDBKeyValue \*kvs = NULL;  
> int more, count, i;  
> int rowLimit = 0; // 0 for unlimited  
> int byteLimit = 0; // 0 for unlimited  
> int iteration = 1;  
> fdb\_bool\_t snapshot = 0;  
> fdb\_bool\_t reverse = 0;  
> char \*json\_string = NULL;
> 
> ```
> // get value
> FDBTransaction *tr;
> db_check_error(fdb_database_create_transaction(db, &tr));
> 
> FDBFuture* f = fdb_transaction_get_range(tr, (const uint8_t *)"", 0, 0, 1, (const uint8_t *)"\xff", 1, 0, 1, rowLimit, byteLimit, FDB_STREAMING_MODE_WANT_ALL, iteration, snapshot, reverse);
> 
> /*Its getting blocked here and doesn't return*/
> wait_and_check_error(f);
> 
> db_check_error(fdb_future_get_keyvalue_array(f, &kvs, &count, &more));
> 
> if (kvs != NULL)
> {
> for (i = 0; i<count; i++)
> {
> printf("Key %.*s Value %.*s\n\n", kvs[i].key_length, (char *)kvs[i].key, kvs[i].value_length, (char *)kvs[i].value);
> }
> }
> 
> fdb_transaction_destroy(tr);
> fdb_future_destroy(f);
> 
> ```
> 
> }
> 
> int init\_db()  
> {  
> // set up network  
> db\_check\_error(fdb\_select\_api\_version(FDB\_API\_VERSION));  
> db\_check\_error(fdb\_setup\_network());
> 
> ```
> // run network
> pthread_create(&network_thread, NULL, (void *)db_run_network, NULL);
> 
> // get cluster
> FDBFuture *clusterFuture = fdb_create_cluster("/etc/fdb/fdb.cluster");
> wait_and_check_error(clusterFuture);
> 
> // get database
> FDBCluster *cluster;
> axstrm_db_check_error(fdb_future_get_cluster(clusterFuture, &cluster));
> fdb_future_destroy(clusterFuture);
> 
> FDBFuture *dbFuture = fdb_cluster_create_database(cluster, (const uint8_t *)"DB", 2);
> wait_and_check_error(dbFuture);
> db_check_error(fdb_future_get_database(dbFuture, &db));
> fdb_future_destroy(dbFuture);
> 
> // read data
> db_retrieve_data();
> 
> return 0;
> 
> ```
> 
> }

It will work if I remove the folder name “fdb”, which created when i run the fdbserver. fdb folder has the storage related files. If I remove the folder and run again it will create new “fdb” folder and it’s working. I’m facing this issue rarely and no idea how to solve this problem. I’m loosing my data frequently if remove that “fdb” folder.

I have created memory using fdbcli (“configure new single memory”). It was created a week before. Still it accessible using fdbcli.

Please let me know the solution for this, how to get the DB data without losing.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![KrzysFR](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/krzysfr/32/43_2.png) [@KrzysFR](https://forums.foundationdb.org/u/KrzysFR)\
**Post date:** [April 23, 2019, 8:09am UTC](https://forums.foundationdb.org/t/indefinite-blocking-of-fdb-future-block-until-ready-even-though-db-is-available/1323/2 "2019-04-23T08:09:58Z")

</div>

Are you, by any chance, running out of disk space?

By default, the cluster will stop accepting transaction when the available disk space runs below a set threshold (\<5% remaining iirc).

Removing the folder will create new space, until it is consumed again by your tests.

---

<div class="post-metadata">

**Author:** ![sakthivelpvs](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@sakthivelpvs](https://forums.foundationdb.org/u/sakthivelpvs)\
**Post date:** [April 26, 2019, 7:06am UTC](https://forums.foundationdb.org/t/indefinite-blocking-of-fdb-future-block-until-ready-even-though-db-is-available/1323/3 "2019-04-26T07:06:08Z")

</div>

Its working. There was an issue with threads and fdb\_run\_network thread was not running. I have solved the thread issue and now it’s working fine.
