We are evaluating Aerospike for an IOT type application. Various clients insert data into the database, other clients see what data has changed, process the data and insert updated information. I’m evaluating whether Aerospike is suitable for our use (clients update the database at rates of 100 ms continuously). I wrote a simple client: Create a set of data records and insert 10 records. Create a second set of groups for the data records. In a forever loop I get the container record (for testing there is a single container with a known name). I then get the data record names assigned to the container. The names are used in a batch get. Within the batch get I process the data records.
If I run this simple client against an Aerospike cluster with a single node in the cluster everything works OK. If I start a second Aerospike server node the cluster now recognizes that there are 2 nodes in the cluster.
My client now generates a segmentation fault on the very first batch get request. If I stop the second server node and re-run, the client executes with no problems. Again, the segmentation fault is on the first batch get so it’s not an issue of looping.
Is there something special that needs to be done by a client?
as_error err;
as_key key;
as_record *rec = NULL;
as_batch *batch = NULL;
as_key_init_str(&key, "test", "Loops", loopName);
as_record_init (&timeUpdate, 4);
// We run forever
while (true)
{
// First we have to get the loop
//key = as_key_new("test", "Loops", loopName);
if ( aerospike_key_get(&aeroServer, &err, NULL, &key, &rec) != AEROSPIKE_OK )
{
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
return 2;
}
// Get the loop name as stored
recordLoopName = as_record_get_str(rec, "name");
// Get the loop times
nextTime.tv_sec = as_record_get_int64(rec, "nextTime", 0);
nextTime.tv_nsec = as_record_get_int64(rec, "nextTimeNsec", 0);
lastTime.tv_sec = as_record_get_int64(rec, "lastTime", 0);
lastTime.tv_nsec = as_record_get_int64(rec, "lastTimeNsec", 0);
// Get the total number of blocks
loopBlockAs = as_record_get_integer(rec, "NumberBlocks");
totalBlocks = as_integer_get(loopBlockAs);
// Now for the block names. It is stored as a blob
blockBytes = as_record_get_bytes(rec, "blocks");
rawBuffer = (char *)as_bytes_get(blockBytes);
blockSize = as_bytes_size(blockBytes);
// We have the internal blob buffer and the blob size, copy to properly casted array
memcpy (gblockNames, rawBuffer, blockSize);
// Now we need to get the blocks
// Batch operations
batch = as_batch_new (totalBlocks);
// Add the keys
for (int i=0; i < totalBlocks; i++)
{
//as_key_init (as_batch_keyat(&batch, i), "test", "Blocks", &gblockNames[i][0]);
as_key_init (as_batch_keyat(batch, i), "test", "Blocks", &gblockNames[i][0]);
//fprintf(stdout, "Adding batch key %i:%s Total:%i\n", i, &gblockNames[i][0],totalBlocks);
//fflush (stdout);
}
// Now issue the get which invokes a callback
if ( aerospike_batch_get(&aeroServer, &err, &batchPolicy, batch, getblocksCallback, NULL) != AEROSPIKE_OK )
{
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
return 2;
}