[zeromq-dev] error handling? assert?

Martin Sustrik sustrik at fastmq.com
Tue Dec 16 11:15:31 CET 2008


> Does ZeroMQ provide error handling for all kinds of errors? Or just for 
> when a client disconnects?
> I am calling ZeroMQ from inside a larger program. When I try to create 
> two global exchanges using the same exchange name, ZeroMQ crashes with 
> the mssage: "locator.cpp:97: vritual void zmq::locator_t::create( ...) 
> Assertion 'cmd == create_ok_id' failed"

Yes. That's the case. How would you like it to behave? Invoking a 
callback function (error handler) is an option...

> So it appears that if ZeroMQ encounters errors it just does an assert 
> and ends up crashing the whole process? In my use case, this is causing 
> a much, much larger server process to crash along with ZeroMQ. This 
> makes it difficult to make my code fault-tolerant.

The idea is that 0MQ is intended primarily for environments with a need 
for high reliability (financial services) thus the policy of hiding 
errors is not tolerable. If there's a bug, application should crash 
(hopefully pretty early during the tests in test env) and the bug should 
be corrected rather than stay in some half-defined state and possibly 
cause some erroneous business transactions to succeed.

Let's consider your case: I assume the problem appears when two 
instances of an application that should have at most one instance 
running, are started, right? In this case, crashing seems to be a pretty 
good thing to do. Letting the second instance run would be potentially 
harmful to your business logic so it's better to crash and thus let the 
user know that there's a bug to fix in the app.


More information about the zeromq-dev mailing list