Some unexpected behaviour with autoheal ?

28 views
Skip to first unread message

Mooky

unread,
Aug 29, 2012, 10:09:20 AM8/29/12
to Hook.io
I am trying to create a set of peer-to-pear hooks that are sending
events to each other (essentially broadcasting events across node
processes/hosts)

I wrote a noddy little pub/sub example (code below) that listens to
messages & sends messages periodically.
I can start a number of them on the same host, and they all receive
each others messages happily (my example also listens to its own
messages).

I can then kill the current "master"/"server" and, as one would
expect, one of the peers takes over as server and all messages are
sent/received as expected.
All great so far.

However, I start to see unexpected behaviour if I kill the expected
successor.

If I start, say, 4 of them, and we have hooks: "hooky", "hooky-0",
"hooky-1", "hooky-2".
"hooky" will be the master & "hooky-0" will be the new master if
"hooky" dies.

If I kill "hooky-0", then kill "hooky" : Rather than "hooky-1"
becoming the new server (as I would expect), I find there is no new
server the remaining hooks no longer receive any messages.

If I kill "hooky-0" and restart it again before killing "hooky": the
behaviour seems unpredictable - sometimes messages continue being
received - sometimes not (I havent figured out a pattern yet).

Is this behaviour expected? Is there something I have misunderstood?

Cheers.

Here is my code:
===============================
var Hook = require('hook.io').Hook;
var hooky = new Hook({
name: "hooky",
silent: false,
autoheal: true
});
hooky.on('hook::ready', function () {
console.log(this.name + " ready");
});
hooky.on('*::hello', function (data) {
console.log(this.name + ' received data ', data);
});
hooky.on('hello', function (data) {
console.log(this.name + ' received data ', data);
});
function hookySend() {
var hello = 'from ' + hooky.name + ' ' + new Date().toString();
hooky.emit('hello', {hello: hello});
}
hooky.start();
setInterval(hookySend, 2000);

Mooky

unread,
Aug 31, 2012, 5:33:19 AM8/31/12
to Hook.io
With further testing, it seems the autoheal is a bit broken?

Marak Squires

unread,
Aug 31, 2012, 5:36:48 AM8/31/12
to hoo...@googlegroups.com
It's possible there are bugs in the paxos implementation. There is no test coverage for it right now, but the code isn't that complex if you wish to dive into it.

I'll accept patches pull requests for this. If not, then it will have to wait until the next major version I'm working on.

Mooky

unread,
Aug 31, 2012, 5:39:48 AM8/31/12
to Hook.io
I can try ...
Reply all
Reply to author
Forward
0 new messages