AEROSPIKE_ERR_REQUEST_INVALID with PHP Client

Faced the error again, but I still don’t know how to fix this.

I only have one node in this cluster.

when I run the script, it only can set 1023 records to the as db and then throw this error.

[4]: AEROSPIKE_ERR_REQUEST_INVALID

I found more info about this error:

Request protocol invalid, or invalid protocol field.

OS info:

Linux ubuntu-luck 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

AS info:

1 :  node
     BB94DCBA012BCF8
2 :  statistics
     cluster_size=1;cluster_key=5BBE1A656BEB582E;cluster_integrity=true;objects=1023;sub-records=0;total-bytes-disk=0;used-bytes-disk=0;free-pct-disk=0;total-bytes-memory=3221225472;used-bytes-memory=154678;data-used-bytes-memory=52086;index-used-bytes-memory=65472;sindex-used-bytes-memory=37120;free-pct-memory=99;stat_read_reqs=1;stat_read_reqs_xdr=0;stat_read_success=1;stat_read_errs_notfound=0;stat_read_errs_other=0;stat_write_reqs=1025;stat_write_reqs_xdr=0;stat_write_success=1023;stat_write_errs=2;stat_xdr_pipe_writes=0;stat_xdr_pipe_miss=0;stat_delete_success=0;stat_rw_timeout=0;udf_read_reqs=0;udf_read_success=0;udf_read_errs_other=0;udf_write_reqs=0;udf_write_success=0;udf_write_err_others=0;udf_delete_reqs=0;udf_delete_success=0;udf_delete_err_others=0;udf_lua_errs=0;udf_scan_rec_reqs=0;udf_query_rec_reqs=0;udf_replica_writes=0;stat_proxy_reqs=0;stat_proxy_reqs_xdr=0;stat_proxy_success=0;stat_proxy_errs=0;stat_ldt_proxy=0;stat_cluster_key_trans_to_proxy_retry=0;stat_cluster_key_transaction_reenqueue=0;stat_slow_trans_queue_push=0;stat_slow_trans_queue_pop=0;stat_slow_trans_queue_batch_pop=0;stat_cluster_key_regular_processed=0;stat_cluster_key_prole_retry=0;stat_cluster_key_err_ack_dup_trans_reenqueue=0;stat_cluster_key_partition_transaction_queue_count=0;stat_cluster_key_err_ack_rw_trans_reenqueue=0;stat_expired_objects=0;stat_evicted_objects=0;stat_deleted_set_objects=0;stat_evicted_objects_time=0;stat_zero_bin_records=0;stat_nsup_deletes_not_shipped=0;err_tsvc_requests=2;err_tsvc_requests_timeout=0;err_out_of_space=0;err_duplicate_proxy_request=0;err_rw_request_not_found=0;err_rw_pending_limit=0;err_rw_cant_put_unique=0;fabric_msgs_sent=0;fabric_msgs_rcvd=0;paxos_principal=BB94DCBA012BCF8;migrate_msgs_sent=0;migrate_msgs_recv=0;migrate_progress_send=0;migrate_progress_recv=0;migrate_num_incoming_accepted=0;migrate_num_incoming_refused=0;queue=0;transactions=1807;reaped_fds=1;scans_active=0;basic_scans_succeeded=0;basic_scans_failed=0;aggr_scans_succeeded=0;aggr_scans_failed=0;udf_bg_scans_succeeded=0;udf_bg_scans_failed=0;batch_index_initiate=0;batch_index_queue=0:0,0:0,0:0,0:0;batch_index_complete=0;batch_index_timeout=0;batch_index_errors=0;batch_index_unused_buffers=0;batch_index_huge_buffers=0;batch_index_created_buffers=0;batch_index_destroyed_buffers=0;batch_initiate=0;batch_queue=0;batch_tree_count=0;batch_timeout=0;batch_errors=0;info_queue=0;delete_queue=0;proxy_in_progress=0;proxy_initiate=0;proxy_action=0;proxy_retry=0;proxy_retry_q_full=0;proxy_unproxy=0;proxy_retry_same_dest=0;proxy_retry_new_dest=0;write_master=1025;write_prole=0;read_dup_prole=0;rw_err_dup_internal=0;rw_err_dup_cluster_key=0;rw_err_dup_send=0;rw_err_write_internal=0;rw_err_write_cluster_key=0;rw_err_write_send=0;rw_err_ack_internal=0;rw_err_ack_nomatch=0;rw_err_ack_badnode=0;client_connections=11;waiting_transactions=0;tree_count=0;record_refs=1023;record_locks=0;migrate_tx_objs=0;migrate_rx_objs=0;ongoing_write_reqs=0;err_storage_queue_full=0;partition_actual=4096;partition_replica=0;partition_desync=0;partition_absent=0;partition_object_count=1023;partition_ref_count=4096;system_free_mem_pct=95;sindex_ucgarbage_found=0;sindex_gc_locktimedout=0;sindex_gc_inactivity_dur=661985;sindex_gc_activity_dur=15;sindex_gc_list_creation_time=8;sindex_gc_list_deletion_time=2;sindex_gc_objects_validated=0;sindex_gc_garbage_found=0;sindex_gc_garbage_cleaned=0;system_swapping=false;err_replica_null_node=0;err_replica_non_null_node=0;err_sync_copy_null_master=0;storage_defrag_corrupt_record=0;err_write_fail_prole_unknown=0;err_write_fail_prole_generation=0;err_write_fail_unknown=0;err_write_fail_key_exists=0;err_write_fail_generation=0;err_write_fail_generation_xdr=0;err_write_fail_bin_exists=0;err_write_fail_parameter=2;err_write_fail_incompatible_type=0;err_write_fail_noxdr=0;err_write_fail_prole_delete=0;err_write_fail_not_found=0;err_write_fail_key_mismatch=0;err_write_fail_record_too_big=0;err_write_fail_bin_name=0;err_write_fail_bin_not_found=0;err_write_fail_forbidden=0;stat_duplicate_operation=0;uptime=681;stat_write_errs_notfound=0;stat_write_errs_other=2;heartbeat_received_self=0;heartbeat_received_foreign=0;query_reqs=0;query_success=0;query_fail=0;query_abort=0;query_avg_rec_count=0;query_short_running=0;query_long_running=0;query_short_queue_full=0;query_long_queue_full=0;query_short_reqs=0;query_long_reqs=0;query_agg=0;query_agg_success=0;query_agg_err=0;query_agg_abort=0;query_agg_avg_rec_count=0;query_lookups=0;query_lookup_success=0;query_lookup_err=0;query_lookup_abort=0;query_lookup_avg_rec_count=0
3 :  features
     float;batch-index;replicas-all;replicas-master;replicas-prole;udf
4 :  cluster-generation
     0
5 :  partition-generation
     1
6 :  edition
     Aerospike Community Edition
7 :  version
     Aerospike Community Edition build 3.6.4
8 :  build
     3.6.4
9 :  services
     
10 :  services-alumni

Here is my code:

<?php
$HOST_ADDR = "127.0.0.1";
$HOST_PORT = 3000;

$config = array (
    "hosts" => array (
        array (
            "addr" => $HOST_ADDR, 
            "port" => $HOST_PORT 
        ) 
    ) 
);
$init_key = 'test';
$db = new Aerospike ( $config, false );
if(! $db->isConnected ()) {
    echo fail ( "Could not connect to host $HOST_ADDR:$HOST_PORT [{$db->errorno()}]: {$db->error()}" );
    exit ( 1 );
}
$count = 7753343;
$time_start = time ();
echo date ( 'Y-m-d H:i:s', $time_start ) . PHP_EOL;

for($i = 0; $i <= $count; $i ++) {
    $url = 'http://www.baidu.com?key=' . $HOST_PORT . $i;
    $code = setShortUrlToAs ( $db, $url, $init_key );
}

$db->close ();
$time_end = time ();
echo date ( 'Y-m-d H:i:s', $time_end ) . PHP_EOL;
echo 'Spend time: ' . ($time_end - $time_start) . PHP_EOL;
function setShortUrlToAs($object, $url, $init_key) {
    $code = getShortKey ();
    $askey = $object->initKey ( $init_key, $code, $code );
    $status = $object->put ( $askey, array (
        $code => $url 
    ), 24 * 60 * 60 );
    if($status == AEROSPIKE::OK) {
        echo $code . '===' . $url . PHP_EOL;
    }
    else {
        echo "[{$object->errorno()}]: {$object->error()}" . PHP_EOL;
        exit ();
    }
    return $code;
}
function getShortKey($len = 12) {
    $cTable = Array (
        48, 
        49, 
        50, 
        51, 
        52, 
        53, 
        54, 
        55, 
        56, 
        57, 
        65, 
        66, 
        67, 
        68, 
        69, 
        70, 
        71, 
        72, 
        73, 
        74, 
        75, 
        76, 
        77, 
        78, 
        79, 
        80, 
        81, 
        82, 
        83, 
        84, 
        85, 
        86, 
        87, 
        88, 
        89, 
        90, 
        97, 
        98, 
        99, 
        100, 
        101, 
        102, 
        103, 
        104, 
        105, 
        106, 
        107, 
        108, 
        109, 
        110, 
        111, 
        112, 
        113, 
        114, 
        115, 
        116, 
        117, 
        118, 
        119, 
        120, 
        121, 
        122 
    );
    
    $newString = "";
    
    for($i = 0; $i < $len; $i ++) {
        $key = chr ( $cTable [array_rand ( $cTable )] );
        $newString .= $key;
    }
    
    return $newString;
}
?>

any help ? thanks

More info from aerospike.log:

Dec 01 2015 05:34:09 GMT: INFO (namespace): (namespace.c::591) at set names limit, can't add FLavEfGBzMo5
Dec 01 2015 05:34:09 GMT: WARNING (rw): (thr_rw.c::4744) {test} write_local: set can't be added <Digest>:0x1ceb301c2f891fb50ce7ee4cc7c738d8eec2d6e4

When you init a new key, a new set is created after save (if not exists):

http://www.aerospike.com/docs/guide/FAQ.html

There is currently a limit of 1023 sets per namespace.

I guess you shouldn’t create such many sets here, you can just save all these data in one set:

Got it. Thanks very much!