Skip to content

Commit

Permalink
Add tag for dual-channel logs (valkey-io#999)
Browse files Browse the repository at this point in the history
This PR introduces a consistent tagging system for dual-channel logs.
The goal is to improve log readability and filterability, making it
easier for operators to manage and analyze log entries.

Resolves valkey-io#986

---------

Signed-off-by: naglera <anagler123@gmail.com>
Signed-off-by: vudiep411 <vdiep@amazon.com>
  • Loading branch information
naglera authored and vudiep411 committed Nov 26, 2024
1 parent 67d40ce commit 882d9dc
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 60 deletions.
21 changes: 11 additions & 10 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -1713,10 +1713,10 @@ void freeClient(client *c) {

/* Log link disconnection with replica */
if (getClientType(c) == CLIENT_TYPE_REPLICA) {
serverLog(LL_NOTICE,
c->flag.repl_rdb_channel ? "Replica %s rdb channel disconnected."
: "Connection with replica %s lost.",
replicationGetReplicaName(c));
if (c->flag.repl_rdb_channel)
dualChannelServerLog(LL_NOTICE, "Replica %s rdb channel disconnected.", replicationGetReplicaName(c));
else
serverLog(LL_NOTICE, "Connection with replica %s lost.", replicationGetReplicaName(c));
}

/* Free the query buffer */
Expand Down Expand Up @@ -1963,14 +1963,15 @@ int freeClientsInAsyncFreeQueue(void) {
if (!c->rdb_client_disconnect_time) {
if (c->conn) connSetReadHandler(c->conn, NULL);
c->rdb_client_disconnect_time = server.unixtime;
serverLog(LL_VERBOSE, "Postpone RDB client id=%llu (%s) free for %d seconds", (unsigned long long)c->id,
replicationGetReplicaName(c), server.wait_before_rdb_client_free);
dualChannelServerLog(LL_VERBOSE, "Postpone RDB client id=%llu (%s) free for %d seconds",
(unsigned long long)c->id, replicationGetReplicaName(c), server.wait_before_rdb_client_free);
}
if (server.unixtime - c->rdb_client_disconnect_time <= server.wait_before_rdb_client_free) continue;
serverLog(LL_NOTICE,
"Replica main channel failed to establish PSYNC within the grace period (%ld seconds). "
"Freeing RDB client %llu.",
(long int)(server.unixtime - c->rdb_client_disconnect_time), (unsigned long long)c->id);
dualChannelServerLog(
LL_NOTICE,
"Replica main channel failed to establish PSYNC within the grace period (%ld seconds). "
"Freeing RDB client %llu.",
(long int)(server.unixtime - c->rdb_client_disconnect_time), (unsigned long long)c->id);
c->flag.protected_rdb_channel = 0;
}

Expand Down
Loading

0 comments on commit 882d9dc

Please sign in to comment.