2016-12-10 4 views
2

Не могли бы вы объяснить, почему метод Aerospike::exists бросает Fatal Error:Проверьте наличие ключа в базе данных существует Aerospike

Код:

$aerospike = new Aerospike(
    [ 
     'hosts' => [ 
      ['addr' => '127.0.0.1', 'port' => 3000] 
     ], 
     'shm' => [], 
    ], 
    false, 
    [] 
); 

$bins = ['value' => 99]; 
$akey = $aerospike->initKey('test', 'cache', 'test-data'); 

$putStatus = $aerospike->put(
    $akey, 
    $bins, 
    0, 
    [Aerospike::OPT_POLICY_KEY => Aerospike::POLICY_KEY_SEND] 
); 
var_dump($putStatus); // Aerospike::OK here 

$deleteStatus = $aerospike->remove($akey); 
var_dump($deleteStatus); // Aerospike::OK here 

$existsStatus = $aerospike->exists($akey, $metadata); // Fatal error 

окружающей среды:

  • Ubuntu 16.04.1
  • PHP 7.0.13
  • Arospike PHP Cient 3.4.13
  • Aerospike Docker Image (Server): aerospike:3.10.1

Тест:

$ php aerospike.php 
/tmp/aerospike.php:24: 
int(0) 
/tmp/aerospike.php:27: 
int(0) 
PHP Fatal error: Aerospike::exists(): exists/getMetadata: 
    unable to fetch the record in /tmp/aerospike.php on line 29 
PHP Stack trace: 
PHP 1. {main}() /tmp/aerospike.php:0 
PHP 2. Aerospike->exists() /tmp/aerospike.php:29 

я нашел в src/aerospike/aerospike_record_operations.c:

if (AEROSPIKE_OK != (status = aerospike_record_operations_exists(as_object_p, &as_key_for_put_record, error_p, metadata_p, options_p TSRMLS_CC))) 
{ 
    DEBUG_PHP_EXT_ERROR("exists/getMetadata: unable to fetch the record"); 
    goto exit; 
} 

и src/aerospike/aerospike_common.h:

#define DEBUG_PHP_EXT_ERROR(args...) DEBUG_PHP_EXT_COMPARE_LEVEL(AS_LOG_LEVEL_ERROR, E_ERROR, args) 

#define DEBUG_PHP_EXT_COMPARE_LEVEL(log_level, php_log_level, args...)   \ 
do {                    \ 
    if (!(((as_log_level) PHP_EXT_AS_LOG_LEVEL_OFF) == php_log_level_set))  \ 
     if (php_log_level_set >= log_level) {          \ 
      php_error_docref(NULL TSRMLS_CC, php_log_level, args);    \ 
      aerospike_helper_log_callback((log_level | 0x08), __func__ TSRMLS_CC, \ 
        __FILE__, __LINE__, ##args);         \ 
     }                   \ 
} while(0) 

Я проверил the documentation, но не нашел ни намека о том, как это может быть исправлено.

Благодаря

ответ

1

Зафиксировано компиляции клиента PHP со следующими флагами:

CFLAGS="-std=gnu99 -g -D__AEROSPIKE_PHP_CLIENT_LOG_LEVEL__=PHP_EXT_AS_LOG_LEVEL_OFF"