zeromq / malamute

The ZeroMQ Enterprise Messaging Broker
Mozilla Public License 2.0
323 stars 77 forks source link

mlm_client_send returns OK when no message was sent #212

Open malanka opened 8 years ago

malanka commented 8 years ago

Hi,

simple example:

# include <malamute.h>

int main () {
    mlm_client_t *client = mlm_client_new();
    mlm_client_connect (client, "ipc://@/malamute", 1000, "myname");

    zmsg_t* msg = zmsg_new ();
    int rv = mlm_client_send (client, "subject", &msg);
    printf ("rv=%d\n", rv);
    mlm_client_destroy (&client);
    return 0;
}

I would expect mlm_client_send return -1 (as message was NOT actually send), but unfortunately it returned 0.

mlm_client_set_producer was intentionally omitted.

jimklimov commented 7 years ago

+1 : according to recent bugs our team dealt with, this misbehavior was still in place, and bit us with some collateral damage.

bluca commented 7 years ago

man zmq_msg_send

 Note
 A successful invocation of zmq_msg_send() does not indicate that the message has been
 transmitted to the network, only that it has been queued on the socket and 0MQ has assumed
 responsibility for the message.

All messages are sent asynchronously, so the synchronous API call cannot know if the message has been sent over the network or not. Only if there were problems when creating it and queueing it up (or HWMs were full, etc)

jimklimov commented 7 years ago

According to our devs (and sorry if I'm playing broken phone here):

(our original issue in our project) is technically resolved by malamute upstream/master - send on unset stream behaves properly, but puts agent into state where calls to set consumer/producer fail. I'm not sure I consider that a bug. (The case was: ) We get a request to publish something before we set the stream, we try to publish, we try to set the stream and the last call fails. The concrete issue was resolved by fixing our race condition, now I am just trying to see if there is something Malamute can do to prevent it from happening again.

So that's about all the summary I have to forward at this time :)