Skip to content

Look into whether heartbeat patch makes sense with more than one server backend (server_connections: 2) #52

Description

@TysonAndre

This has almost always been used with server_connections: 1

A struct server can have more than one connection (struct conn), though it isn't recommended

When restoring a connection, the heartbeat patch checks if the connection is healthy. However, if a server has other healthy connections, it may not make sense to set the status of the entire server (server->fail) based on recent failures, and this changing server->fail due to an unrelated connection's status may violate some assumptions about the state machine

void
server_restore(struct context *ctx, struct conn *conn)
{
    struct server *server;

    server = (struct server *)(conn->owner);
    ASSERT(server != NULL);

    if (server->fail == FAIL_STATUS_NORMAL) {
        return;
    }

    /* If the server's in an error state: On adding a server back into the pool send a heartbeat command to check if it is still healthy and should still be in the pool (?) */
    if (send_heartbeat(ctx, conn, server) != NC_OK) {
        log_error("Unexpectedly failed to send a heartbeat to the server to attempt reconnection");
    }
}
void
server_close(struct context *ctx, struct conn *conn)
{
    rstatus_t status;
    struct msg *msg, *nmsg; /* current and next message */
    struct conn *c_conn;    /* peer client connection */

    ASSERT(!conn->client && !conn->proxy);

    server_close_stats(ctx, conn->owner, conn->err, conn->eof,
                       conn->connected);

    conn->connected = false;

    if (conn->sd < 0) {
        server_failure(ctx, conn->owner);
        conn->unref(conn);
        conn_put(conn);
        return;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions