php-zookeeper
php-zookeeper copied to clipboard
Reconnect failure with watches
Minimal script to reproduce is below.
Steps to reproduce:
- Start ZK Server, Start the client below
- Stop Server, wait a moment, Start Server.
- Upon reconnecting it will fail. You can prevent it from failing by not setting a watch during your first connection.
Zookeeper::setDebugLevel(Zookeeper::LOG_LEVEL_DEBUG);
class zookeeper_bug1 extends Zookeeper {
function connect_cb($type, $event, $string) {
echo "Connect Callback\n";
if ($event == Zookeeper::CONNECTED_STATE ) {
//With watch, fails upon reconnect
$this->getChildren('/zookeeper', array($this, 'watcher_cb'));
//No watch works fine
//$this->getChildren('/zookeeper');
}
}
function watcher_cb($type, $event, $string){
echo "Watcher Callback: type=$type event=$event string=$string\n";
}
}
$zk = new zookeeper_bug1();
$zk->connect('localhost:2181', array($zk, 'connect_cb'));
while(true){
usleep(100000);
}
The error it outputs:
2011-04-22 04:31:33,889:3426(0x40a26940):ZOO_INFO@check_events@1585: initiated connection to server [127.0.0.1:2181]
2011-04-22 04:31:33,889:3426(0x40a26940):ZOO_INFO@check_events@1632: session establishment complete on server [127.0.0.1:2181], sessionId=0x12f7cf90f130000, negotiated timeout=10000
2011-04-22 04:31:33,889:3426(0x40a26940):ZOO_DEBUG@send_set_watches@1312: Sending set watches request to 127.0.0.1:2181
2011-04-22 04:31:33,889:3426(0x40a26940):ZOO_DEBUG@check_events@1638: Calling a watcher for a ZOO_SESSION_EVENT and the state=ZOO_CONNECTED_STATE
2011-04-22 04:31:33,895:3426(0x42498940):ZOO_DEBUG@process_completions@1765: Calling a watcher for node [], type = -1 event=ZOO_SESSION_EVENT
PHP Fatal error: Corrupted fcall_info provided to zend_call_function() in zookeeper.php on line 28
Fatal error: Corrupted fcall_info provided to zend_call_function() in zookeeper.php on line 28
2011-04-22 04:31:33,896:3426(0x40a26940):ZOO_DEBUG@do_io@317: IO thread terminated
Simplify the sample client to this:
Zookeeper::setDebugLevel(Zookeeper::LOG_LEVEL_DEBUG);
class zookeeper_bug1
{
public function connect_cb($type, $event, $string) {
echo "Connect Callback\n";
}
}
$zk = new Zookeeper();
$zk->connect('localhost:2181', array('zookeeper_bug1', 'connect_cb'));
while(true){
usleep(100000);
}
the fault disappears.
Maybe it's related to the type of callback?
@andreiz
Would you try php-zookeeper/php-zookeeper@ab66987 ?