Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TysonAndre opened this issue May 7, 2021 · 0 comments

Comments

@TysonAndre
Copy link

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;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant