我在电子商务网站遇到一个非常奇怪的问题:更新订单状态的一些查询(但不是全部)因某些神秘原因而失败。
在客户成功付款后,支付网关会调用在线商店中的php脚本,该脚本应更新相应订单的状态(从“待处理”到“已确认”)。
这适用于某些情况,但不适用于其他情况。我注意到当从特定的IP(和相应的端口)调用回调URL时,order_status_update()的模式是有效的,而不是从另一个IP调用的。
我已经完成了代码并使用一堆日志记录对其进行了检测,并且所有内容都检查到了查询级别,但在一种情况下它可以正常工作,另一种情况则是失败。
我能看到的唯一区别是:
1)服务器的IP调用回调脚本,
2)服务器的远程端口调用回调脚本。
据我所知,调用的$ _SERVER ['REMOTE_ADDR']不应对执行的任何内容产生影响(除非脚本显然做了相应的事情,但事实并非如此),所以我'我想知道$ _SERVER ['REMOTE_PORT']是否会对MySQL /数据库产生影响,导致查询可能失败?
当脚本/查询成功时,REMOTE_PORT为18436,当它失败时,REMOTE_PORT为49495。
我已经从两个订单附加了日志记录,第一个是成功的,然后是第二个失败 - 你可以看到它们实际上是相同的(除了order_id和mdate,正如预期的那样)
什么时候有效:
nab_notify - 使用d [] =调用order_status_update:数组\ n(\ n [order_id] => 2860 \ n [order_status] => C \ n [notify_customer] => Y \ n)\ n
ps_order :: order_status_update - d [] =数组\ n(\ n [order_id] => 2860 \ n [order_status] => C \ n [notify_customer] => Y \ n)\ n
ps_order :: order_status_update - curr_order_status:order_status:C notify_customer:1
ps_order :: order_status_update - UPDATE vm_orders(1)w / fields [] = Array \ n(\ n [order_status] => C \ n [mdate] => 1314093024 \ n)\ n
ps_order :: order_status_update - UPDATE vm_orders(2)order_id:[2860]
ps_order :: order_status_update - UPDATE vm_orders(3)QUERY:[UPDATE #__vm_orders
SET order_status
='C',\ n mdate
='1314093024'\ nWHERE order_id ='2860']
ps_order :: order_status_update - UPDATE vm_orders(4)qresult:[1]
当它不起作用时:
nab_notify - calling order_status_update with d[]=:Array\n(\n [order_id] => 2863\n [order_status] => C\n [notify_customer] => Y\n)\n
ps_order::order_status_update - d[]=Array\n(\n [order_id] => 2863\n [order_status] => C\n [notify_customer] => Y\n)\n
ps_order::order_status_update - curr_order_status: order_status:C notify_customer:1
ps_order::order_status_update - UPDATE vm_orders (1) w/fields[]=Array\n(\n [order_status] => C\n [mdate] => 1314137858\n)\n
ps_order::order_status_update - UPDATE vm_orders (2) order_id:[2863]
ps_order::order_status_update - UPDATE vm_orders (3) QUERY:[UPDATE `#__vm_orders` SET `order_status` = 'C',\n`mdate` = '1314137858'\nWHERE order_id='2863']
ps_order::order_status_update - UPDATE vm_orders (4) qresult:[0]
鉴于“相同”的查询,有人可以解释为什么一个人会失败而另一个人会成功吗?
谢谢, 埃里克
更新1:我添加了查询级别日志记录并发现了一些错误,日志显示:
ERROR 2006 - MySQL服务器已经消失
...但奇怪的是并非在这个特定会话中的所有查询(猜测这是令人鼓舞的?)。我留下了痕迹中的断线,以防它们有一个方位。
我经过几次搜索和其他论坛帖子后,检查了php设置并查看
max_execution_time = 60
max_input_time = 60
应该有足够的时间吗?
奇怪的是,只有当从特定IP(与其他订单状态未更新时相同的IP)完成对特定URL的请求时,才会出现这种情况。
2011-08-25 02:54:48 - JDatabaseMySQL::query - SQL=SELECT `order_number`, `user_id`, `order_subtotal`,
`order_total`, `order_currency`, `order_tax`, 'order_status',
`order_shipping_tax`, `coupon_discount`, `order_discount`
FROM `jos_vm_orders`
WHERE `order_id`='2868'
2011-08-25 02:54:48 - JDatabaseMySQL::query - !!!! ERROR !!!! 2006 - MySQL server has gone away SQL=SELECT `order_number`, `user_id`, `order_subtotal`,
`order_total`, `order_currency`, `order_tax`, 'order_status',
`order_shipping_tax`, `coupon_discount`, `order_discount`
FROM `jos_vm_orders`
WHERE `order_id`='2868'
2011-08-25 02:54:48 - JDatabaseMySQL::query - SQL=SELECT user_id,order_total,order_status FROM jos_vm_orders WHERE jos_vm_orders.order_id='2868'
2011-08-25 02:54:48 - JDatabaseMySQL::query - !!!! ERROR !!!! 2006 - MySQL server has gone away SQL=SELECT user_id,order_total,order_status FROM jos_vm_orders WHERE jos_vm_orders.order_id='2868'
2011-08-25 02:54:48 - JDatabaseMySQL::query - SQL=UPDATE `jos_vm_orders` SET `order_status` = 'C',
`mdate` = '1314240914'
WHERE order_id='2868'
2011-08-25 02:54:48 - JDatabaseMySQL::query - !!!! ERROR !!!! 2006 - MySQL server has gone away SQL=UPDATE `jos_vm_orders` SET `order_status` = 'C',
`mdate` = '1314240914'
WHERE order_id='2868'
2011-08-25 02:54:48 - JDatabaseMySQL::query - SQL=INSERT INTO `jos_vm_order_history` (`order_id`,
`order_status_code`,
`date_added`,
`customer_notified`,
`comments`) VALUES (
'2868'
,'C'
,'2011-08-25 12:25:14'
,'1'
,''
)
2011-08-25 02:54:48 - JDatabaseMySQL::query - !!!! ERROR !!!! 2006 - MySQL server has gone away SQL=INSERT INTO `jos_vm_order_history` (`order_id`,
`order_status_code`,
`date_added`,
`customer_notified`,
`comments`) VALUES (
'2868'
,'C'
,'2011-08-25 12:25:14'
,'1'
,''
)
2011-08-25 02:54:48 - JDatabaseMySQL::query - SQL=SELECT order_item_id, event_reg_id FROM jos_vm_order_item WHERE order_id=2868
2011-08-25 02:54:48 - JDatabaseMySQL::query - !!!! ERROR !!!! 2006 - MySQL server has gone away SQL=SELECT order_item_id, event_reg_id FROM jos_vm_order_item WHERE order_id=2868
2011-08-25 02:54:48 - JDatabaseMySQL::query - SQL=SELECT id FROM jos_menu WHERE link='index.php?option=com_virtuemart' AND published=1
2011-08-25 02:54:48 - JDatabaseMySQL::query - !!!! ERROR !!!! 2006 - MySQL server has gone away SQL=SELECT id FROM jos_menu WHERE link='index.php?option=com_virtuemart' AND published=1
2011-08-25 02:54:48 - JDatabaseMySQL::query - SQL=SELECT vendor_name,contact_email FROM jos_vm_vendor WHERE vendor_id='1'
2011-08-25 02:54:48 - JDatabaseMySQL::query - !!!! ERROR !!!! 2006 - MySQL server has gone away SQL=SELECT vendor_name,contact_email FROM jos_vm_vendor WHERE vendor_id='1'
2011-08-25 02:54:48 - JDatabaseMySQL::query - SQL=SELECT first_name,last_name,user_email,order_status_name,country,order_currency FROM jos_vm_order_user_info,jos_vm_orders,jos_vm_order_status WHERE jos_vm_orders.order_id = '2868' AND jos_vm_orders.user_id = jos_vm_order_user_info.user_id AND jos_vm_orders.order_id = jos_vm_order_user_info.order_id AND order_status = order_status_code
2011-08-25 02:54:48 - JDatabaseMySQL::query - !!!! ERROR !!!! 2006 - MySQL server has gone away SQL=SELECT first_name,last_name,user_email,order_status_name,country,order_currency FROM jos_vm_order_user_info,jos_vm_orders,jos_vm_order_status WHERE jos_vm_orders.order_id = '2868' AND jos_vm_orders.user_id = jos_vm_order_user_info.user_id AND jos_vm_orders.order_id = jos_vm_order_user_info.order_id AND order_status = order_status_code