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

Misleading logs when reusing a connection #129

Open
rohitpaulk opened this issue Feb 21, 2024 · 4 comments
Open

Misleading logs when reusing a connection #129

rohitpaulk opened this issue Feb 21, 2024 · 4 comments

Comments

@rohitpaulk
Copy link
Member

rohitpaulk commented Feb 21, 2024

When we reuse a connection to send multiple commands, we still emit logs like this:

$ redis-cli SET a b
$ redis-cli SET b c

This can be misleading, giving the impression that these commands will be sent by different connections.

Thanks to @rsalmei for pointing this out!

Copy link

linear bot commented Feb 21, 2024

@rohitpaulk
Copy link
Member Author

Let's instead do this:

[client-1]: Sending command "SET a b"
[client-1]: Sending command "SET b c"

And let's name these prefixes in a way that make sense for the stage. For example, if it's a replica sending these commands, let's use [replica-1] as the prefix.

@rsalmei
Copy link

rsalmei commented Feb 21, 2024

That's great, thank you, Paul!

I wasn't expecting that three redis-cli commands would end up on a single connection.
And I especially liked your suggestion of also adjusting the prefixes. In the logs below, replication-11 could be a single divider line, and the prefixes would always reflect the actual source, i.e., [x] y would mean "The action y was made by/originated from x".

Thanks again.

remote: [replication-11] Setting key foo to 123
remote: [replication-11] $ redis-cli SET foo 123
remote: [replication-11] Setting key bar to 456
remote: [replication-11] $ redis-cli SET bar 456
remote: [replication-11] Setting key baz to 789
remote: [replication-11] $ redis-cli SET baz 789
remote: [your_program] Received: Ok("*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n*3\r\n$3\r\nSET\r\n$3\r\nbar\r\n$3\r\n456\r\n*3\r\n$3\r\nSET\r\n$3\r\nbaz\r\n$3\r\n789\r\n")
remote: [your_program] <- Failure("Array([BulkString(\"SET\"), BulkString(\"foo\"), BulkString(\"123\")]) remaining 62")

@rohitpaulk
Copy link
Member Author

We've decided to emulate redis-cli a bit more closely:

[client-1] $ redis-cli SET foo bar
[client-1] > SET bar 234

The first command will stay as-is, and every next command will be logged with > as the prefix instead.

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

2 participants