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.