ctdbd_conn: Generalise inaccurate error message
authorMartin Schwenke <martin@meltin.net>
Fri, 5 Oct 2018 04:04:18 +0000 (14:04 +1000)
committerVolker Lendecke <vl@samba.org>
Fri, 5 Oct 2018 14:16:29 +0000 (16:16 +0200)
Seeing:

  ctdb_read_packet failed: Cannot allocate memory
  [...,  0] ../source3/lib/ctdbd_conn.c:121(cluster_fatal)
  cluster fatal event: ctdbd died

The error is due to a memory allocation failure rather than ctdbd
dying.  However, the error message makes people wonder why ctdbd died.

Another alternative would be to wrap cluster_fatal() and have the
wrapper interpret the return value from ctdb_read_packet() to choose
from a set of more precise messages to pass to cluster_fatal().  For a
memory allocation it isn't strictly necessary to call cluster_fatal(),
but all is probably lost and it is still probably better to try to
exit cleanly as soon as possible instead of crashing somewhere.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Oct  5 16:16:29 CEST 2018 on sn-devel-144

source3/lib/ctdbd_conn.c

index dc6aa28231612894734811711fa371a34ad68fe6..d5fac572d3c94402798c63d2fcff999578502ab1 100644 (file)
@@ -405,8 +405,8 @@ static int ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
 
        ret = ctdb_read_packet(conn->fd, conn->timeout, mem_ctx, &hdr);
        if (ret != 0) {
-               DEBUG(0, ("ctdb_read_packet failed: %s\n", strerror(ret)));
-               cluster_fatal("ctdbd died\n");
+               DBG_ERR("ctdb_read_packet failed: %s\n", strerror(ret));
+               cluster_fatal("failed to read data from ctdbd\n");
        }
 
        DEBUG(11, ("Received ctdb packet\n"));
@@ -601,8 +601,8 @@ void ctdbd_socket_readable(struct tevent_context *ev,
 
        ret = ctdb_read_packet(conn->fd, conn->timeout, talloc_tos(), &hdr);
        if (ret != 0) {
-               DEBUG(0, ("ctdb_read_packet failed: %s\n", strerror(ret)));
-               cluster_fatal("ctdbd died\n");
+               DBG_ERR("ctdb_read_packet failed: %s\n", strerror(ret));
+               cluster_fatal("failed to read data from ctdbd\n");
        }
 
        ret = ctdb_handle_message(ev, conn, hdr);
@@ -1082,9 +1082,8 @@ int ctdbd_traverse(struct ctdbd_connection *conn, uint32_t db_id,
 
                ret = ctdb_read_packet(conn->fd, conn->timeout, conn, &hdr);
                if (ret != 0) {
-                       DEBUG(0, ("ctdb_read_packet failed: %s\n",
-                                 strerror(ret)));
-                       cluster_fatal("ctdbd died\n");
+                       DBG_ERR("ctdb_read_packet failed: %s\n", strerror(ret));
+                       cluster_fatal("failed to read data from ctdbd\n");
                }
 
                if (hdr->operation != CTDB_REQ_MESSAGE) {