我在Debian机器上使用Apache 2.4和PHP-FPM 7.0以及Aerospike扩展版本3.4.14
我有一个具有以下结构的集合:
| PK |价值| async_id | paxPrice |航空公司|机场| depAirport | endAirport | takeDep | takeRet | landDep | landRet | flightChange | connectionTime | moxedAirlines |腿|
以下是一个示例条目:
“m_0a5c24dcf0e461127060839526d366ab_Sabre_126”| “一个:5:{S:5:” 价格 “;一个:14:{S:5:” 总 “; d:11663.839999999998; S:11:” pricePerPax “; d:1943.97; S:8:” totalflt” ; d:11663.839999999998; S:9: “baseprice”; d:10459.799999999997; S:3: “税”; d:1024.04; S:10: “servicefee”; I:180; S:11: “markupprice”; d :5409.9000000000005; S:11:“剂 | “0a5c24dcf0e461127060839526d366ab”| 1943.97 |列表('[“OS”,“BA”]') |列表('[]')| “SOF”|列表('[]')| “11:05”| “11:05”| “15:50”| “15:50”| 2 | 250 | 1 | 1 |
所以基本上在值bin中我有一个序列化对象和其他bin中的数组/字符串/ int。 此集合中有196行/条目。
我正在尝试获取由我指定async_id的所有行的列表,并通过paxPrice对它们进行排序,因此我创建了以下lua:
function filter_order(element,param)
local function mapper(rec)
local element = map()
element["paxPrice"] = rec["paxPrice"]
element["async_id"] = rec["async_id"]
return element
end
local function accumulate(currentList, nextElement)
local paxPrice = nextElement["paxPrice"]
info("current:"..tostring(currentList).." next:"..tostring(nextElement))
if currentList[paxPrice] == nil then
currentList[paxPrice] = list()
end
list.append(currentList[paxPrice], nextElement)
return currentList
end
local function mymerge(a,b)
return list.merge(a,b)
end
local function reducer(this,that)
return map.merge(this,that,mymerge)
end
return element:map(mapper):aggregate(map{}, accumulate):reduce(reducer)
end
然后在php中执行此脚本(其中$ this->缓存引用了aerospike缓存):
$where = \Aerospike::predicateEquals("search_async_id",'0a5c24dcf0e461127060839526d366ab');
$result=[];
$this->cache->getDB()->aggregate($this->cache->getNamespace(),'search_results',$where,'filter_order','filter_order',["5"], $result);
var_dump($result);
exit();
但是,这会导致浏览器中的错误500以及apache日志中的以下内容:
[Mon May 29 09:22:20.018040 2017] [fastcgi:error] [pid 7533:tid 140333425817344] (104)Connection reset by peer: [client 95.169.214.202:64970] FastCGI: comm with server "/usr/lib/cgi-bin/php7.0" aborted: read failed
[Mon May 29 09:22:20.018181 2017] [fastcgi:error] [pid 7533:tid 140333425817344] [client 95.169.214.202:64970] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php7.0
我在php-fpm.log中的每次执行中看到的是:
[29-May-2017 09:19:22] WARNING: [pool www] child 8923 exited on signal 11 (SIGSEGV) after 949.301664 seconds from start
[29-May-2017 09:19:22] NOTICE: [pool www] child 9081 started
在aerospike.log中我得到了这个,这使我的服务工作正常:
........
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:496) [ENTER] urecord(0x7f6277bdcfe0) name(0x40dd2208)[async_id] dirty(0)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:225) [ENTER] Opening record key:<Digest>:0xe3ff8ebe962d161a9e90535ff69ca29026100d6b
May 29 2017 09:56:43 GMT: INFO (aggr): (/opt/aerospike/usr/udf/lua/filter_order.lua:11) current:{} next:{"paxPrice":1831.88, "async_id":"0a5c24dcf0e461127060839526d366ab"}
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:84) [ENTER] Opening record key:<Digest>:0xe3ff8ebe962d161a9e90535ff69ca29026100d6b
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:286) [ENTER] Closing record key:<Digest>:0xd00f17e1eb4d4fa11e9aac61dd3cf6fd53b5dbda
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:462) [ENTER] NumUpdates(2)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:712) [ENTER] rec(0x7f6253e18220) name(paxPrice)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:445) [ENTER] BinName(paxPrice)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:496) [ENTER] urecord(0x7f62773dbfe0) name(0x4149d0c0)[paxPrice] dirty(0)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:225) [ENTER] Opening record key:<Digest>:0xf47f9a9d562f0c408346d78326580d75bf75d2f5
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:712) [ENTER] rec(0x7f6253e18220) name(async_id)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:84) [ENTER] Opening record key:<Digest>:0xf47f9a9d562f0c408346d78326580d75bf75d2f5
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:712) [ENTER] rec(0x7f6253c0ef40) name(paxPrice)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:445) [ENTER] BinName(paxPrice)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:496) [ENTER] urecord(0x7f6276bdafe0) name(0x416220c0)[paxPrice] dirty(0)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:712) [ENTER] rec(0x7f6253c0ef40) name(async_id)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:445) [ENTER] BinName(async_id)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:496) [ENTER] urecord(0x7f6276bdafe0) name(0x416221d0)[async_id] dirty(0)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:445) [ENTER] BinName(async_id)
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:496) [ENTER] urecord(0x7f62773dbfe0) name(0x4149d1d0)[async_id] dirty(0)
May 29 2017 09:56:43 GMT: INFO (aggr): (/opt/aerospike/usr/udf/lua/filter_order.lua:11) current:{} next:{"paxPrice":514.27, "async_id":"0a5c24dcf0e461127060839526d366ab"}
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:286) [ENTER] Closing record key:<Digest>:0xf47f9a9d562f0c408346d78326580d75bf75d2f5
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:462) [ENTER] NumUpdates(2)
May 29 2017 09:56:43 GMT: INFO (aggr): (/opt/aerospike/usr/udf/lua/filter_order.lua:11) current:{} next:{"paxPrice":517.85, "async_id":"0a5c24dcf0e461127060839526d366ab"}
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:286) [ENTER] Closing record key:<Digest>:0xe3ff8ebe962d161a9e90535ff69ca29026100d6b
May 29 2017 09:56:43 GMT: DEBUG (udf): (udf_record.c:462) [ENTER] NumUpdates(2)
May 29 2017 09:56:43 GMT: INFO (scan): (scan.c:1098) finished aggregation scan job 11754624473865748080 (0)
May 29 2017 09:56:44 GMT: DEBUG (demarshal): (thr_demarshal.c:646) running on CPU 3
May 29 2017 09:56:44 GMT: DEBUG (paxos): (paxos.c:2005) PAXOS message with ID 13 received from node bb9b25b63000056
May 29 2017 09:56:44 GMT: DEBUG (paxos): (paxos.c:2716) unwrapped | received paxos message from node bb9b25b63000056 command RETRANSMIT_CHECK (13)
May 29 2017 09:56:44 GMT: DEBUG (sindex): (secondary_index.c:1507) Index mytedev:search_paxPrice in 2 state Reserved to reference count 2 < 2 at base/thr_sindex.c:329
May 29 2017 09:56:44 GMT: DEBUG (demarshal): (thr_demarshal.c:175) Reaping FD 29 as requested
May 29 2017 09:56:44 GMT: DEBUG (cf:socket): (socket.c:1185) Closing FD 29
May 29 2017 09:56:44 GMT: DEBUG (demarshal): (thr_demarshal.c:175) Reaping FD 30 as requested
May 29 2017 09:56:44 GMT: DEBUG (cf:socket): (socket.c:1185) Closing FD 30
May 29 2017 09:56:45 GMT: DEBUG (demarshal): (thr_demarshal.c:646) running on CPU 3
May 29 2017 09:56:45 GMT: DEBUG (sindex): (secondary_index.c:1507) Index mytedev:search_paxPrice in 2 state Reserved to reference count 2 < 2 at base/thr_sindex.c:329
May 29 2017 09:56:46 GMT: DEBUG (demarshal): (thr_demarshal.c:646) running on CPU 3
May 29 2017 09:56:46 GMT: DEBUG (paxos): (paxos.c:2005) PAXOS message with ID 13 received from node bb9b25b63000056
May 29 2017 09:56:46 GMT: DEBUG (paxos): (paxos.c:2716) unwrapped | received paxos message from node bb9b25b63000056 command RETRANSMIT_CHECK (13)
所以我去检查错误是什么,dmesg给了我这个:
.....
[4222171.116554] php-fpm7.0[8888]: segfault at 0 ip 00007fc4ab1e1c3a sp 00007fc49cb25708 error 4 in libc-2.19.so[7fc4ab160000+1a1000]
[4222172.079863] php-fpm7.0[8906]: segfault at 1f ip 00007fc4ab1e1c3a sp 00007fc49cb25708 error 4 in libc-2.19.so[7fc4ab160000+1a1000]
[4222399.581538] php-fpm7.0[8929]: segfault at 0 ip 00007fc4ab1e1c3a sp 00007fc49cb25708 error 4 in libc-2.19.so[7fc4ab160000+1a1000]
[4222879.548465] php-fpm7.0[9038]: segfault at 20 ip 00007fc4ab1e1c3a sp 00007fc49cb25708 error 4 in libc-2.19.so[7fc4ab160000+1a1000]
[4223089.161566] php-fpm7.0[9063]: segfault at 0 ip 00007fc4ab1e1c3a sp 00007fc49cb25708 error 4 in libc-2.19.so[7fc4ab160000+1a1000]
[4223121.381333] traps: php-fpm7.0[9010] general protection ip:7fc4ab1e1c3a sp:7fc49cb25708 error:0 in libc-2.19.so[7fc4ab160000+1a1000]
[4223298.943340] php-fpm7.0[9116]: segfault at 20 ip 00007f9561724c3a sp 00007f9552f25708 error 4 in libc-2.19.so[7f95616a3000+1a1000]
[4225362.832272] php-fpm7.0[9288]: segfault at 0 ip 00007f9561724c3a sp 00007f9552f25708 error 4 in libc-2.19.so[7f95616a3000+1a1000]
核心转储和gdb显示:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `php-fpm: pool www '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f9561724c3a in strlen () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) t
[Current thread is 1 (Thread 0x7f9552f26700 (LWP 9116))]
(gdb) bt
#0 0x00007f9561724c3a in strlen () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007f95600246f4 in ADD_MAP_ASSOC_LIST (as=0x7f9560c73c60, key=0x7f954403ff70, value=0x7f953c025460, array=0x7f9552f25860, err=0x7ffd4e23fe30)
at /opt/vendor/aerospike/aerospike-client-php/src/aerospike/aerospike_transform.c:1274
#2 0x00007f9560025854 in AS_MAP_GET_CALLBACK (key=0x7f954403ff70, value=0x7f953c025460, array=0x7f9552f25860)
at /opt/vendor/aerospike/aerospike-client-php/src/aerospike/aerospike_transform.c:1425
#3 0x00007f9560076510 in as_hashmap_foreach (map=0x7f9544035f50, callback=0x7f9560025367 <AS_MAP_GET_CALLBACK>, udata=0x7f9552f25860) at src/main/aerospike/as_hashmap.c:498
#4 0x00007f95600213c2 in as_map_foreach (map=0x7f9544035f50, callback=0x7f9560025367 <AS_MAP_GET_CALLBACK>, udata=0x7f9552f25860)
at /opt/vendor/aerospike/aerospike-client-php/src/aerospike/../aerospike-client-c/include/aerospike/as_map.h:357
#5 0x00007f95600244d5 in ADD_LIST_APPEND_MAP (as=0x7f9560c73c60, key=0x0, value=0x7f9544035f50, array=0x7ffd4e177b80, err=0x7ffd4e23fe30)
at /opt/vendor/aerospike/aerospike-client-php/src/aerospike/aerospike_transform.c:1223
#6 0x00007f9560025ed1 in AS_AGGREGATE_GET (as=0x7f9560c73c60, key=0x0, value=0x7f9544035f50, array=0x7ffd4e177b80)
at /opt/vendor/aerospike/aerospike-client-php/src/aerospike/aerospike_transform.c:1549
#7 0x00007f956001e66e in aerospike_helper_aggregate_callback (val_p=0x7f9544035f50, udata_p=0x7ffd4e177b80) at /opt/vendor/aerospike/aerospike-client-php/src/aerospike/aerospike_helper.c:755
#8 0x00007f956005c747 in as_output_stream_write (s=<optimized out>, val=0x7f9544035f50) at src/main/aerospike/aerospike_query.c:182
#9 0x00007f9560083977 in as_stream_write (value=<optimized out>, stream=0x7f9552f25e60) at ../../modules/common/target/Linux-x86_64/include/aerospike/as_stream.h:231
#10 mod_lua_stream_write (l=0x7f95440008c0) at src/main/mod_lua_stream.c:113
#11 0x00007f9560088c14 in luaD_precall () from /usr/lib/php/20151012/aerospike.so
#12 0x00007f9560097f38 in luaV_execute () from /usr/lib/php/20151012/aerospike.so
#13 0x00007f956008906d in luaD_call () from /usr/lib/php/20151012/aerospike.so
#14 0x00007f95600882ea in luaD_rawrunprotected () from /usr/lib/php/20151012/aerospike.so
#15 0x00007f956008921f in luaD_pcall () from /usr/lib/php/20151012/aerospike.so
#16 0x00007f9560085291 in lua_pcall () from /usr/lib/php/20151012/aerospike.so
#17 0x00007f956007dd75 in apply (l=l@entry=0x7f95440008c0, err=err@entry=25, argc=argc@entry=5, res=res@entry=0x7f9552f25e80, is_stream=is_stream@entry=true, udf_ctx=0x7f9552f25e40)
at src/main/mod_lua.c:858
#18 0x00007f956007e844 in apply_stream (m=<optimized out>, udf_ctx=0x7f9552f25e40, filename=0x7ffd4e177c39 "filter_order", function=0x7ffd4e177c79 "filter_order", istream=0x7ffd4e177a10,
args=<optimized out>, ostream=0x7f9552f25e60, res=0x7f9552f25e80) at src/main/mod_lua.c:1289
#19 0x00007f956005c8d3 in as_query_aggregate (data=0x7ffd4e177a30) at src/main/aerospike/aerospike_query.c:884
#20 0x00007f9560078264 in as_thread_worker (data=0x7f9564d99b08) at src/main/aerospike/as_thread_pool.c:52
#21 0x00007f9561a56064 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#22 0x00007f956178b62d in clone () from /lib/x86_64-linux-gnu/libc.so.6
(gdb)
我认为这是一个空中客户问题,但我可能错了。关于这个的任何想法?
答案 0 :(得分:1)
问题,如https://github.com/aerospike/aerospike-client-php/issues/142中所述,结果是数组的键(有时)是浮点变量,导致段错误。 所以问题实际上在lua文件中,应该是:
local paxPrice = tostring(nextElement["paxPrice"])