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

memory usage command passes key as String instead of using the codec #2424

Closed
kell0gg opened this issue Jun 21, 2023 · 0 comments
Closed

memory usage command passes key as String instead of using the codec #2424

kell0gg opened this issue Jun 21, 2023 · 0 comments
Labels
type: bug A general bug
Milestone

Comments

@kell0gg
Copy link

kell0gg commented Jun 21, 2023

Bug Report

Current Behavior

when I run the code below,

        val key = "TESTKEY ¿" 
        val client = RedisClient.create(uri)
        val connection = client.connect()
        connection.sync().clusterKeyslot(key)
        connection.sync().memoryUsage(key)

the tcpdump result in redis server look like this,

/data # tcpdump -Anni any 'port 6379' | grep "TESTKEY"
tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
06:22:44.655951 eth0  In  IP 10.240.150.21.41454 > 172.28.49.71.6379: Flags [P.], seq 23:70, ack 149, win 237, options [nop,nop,TS val 1138193265 ecr 612931023], length 47: RESP "CLUSTER" "KEYSLOT" "TESTKEY M-BM-?"
TESTKEY ..
06:22:47.509431 eth0  In  IP 10.240.150.21.41454 > 172.28.49.71.6379: Flags [P.], seq 70:112, ack 157, win 237, options [nop,nop,TS val 1138196118 ecr 612931773], length 42: RESP "MEMORY" "USAGE" "TESTKEY M-?"
TESTKEY .

Environment

  • Lettuce version(s): 6.2.4.RELEASE
  • Redis version: 6.2.7

Possible Solution

command builder doesn't seem to use addKey() when adding a key for memory usage only.

https://github.com/lettuce-io/lettuce-core/blob/main/src/main/java/io/lettuce/core/RedisCommandBuilder.java#L1734-L1736

  • asis
    Command<K, V, Long> memoryUsage(K key) {
        return createCommand(MEMORY, new IntegerOutput<>(codec), new CommandArgs<>(codec).add(USAGE).add(key.toString()));
    }
  • tobe
    Command<K, V, Long> memoryUsage(K key) {
        return createCommand(MEMORY, new IntegerOutput<>(codec), new CommandArgs<>(codec).add(USAGE).addKey(key));
    }

Additional context

@kell0gg kell0gg changed the title In memory usage command, key is codec is not applied In memory usage command, key codec is not applied Jun 21, 2023
@mp911de mp911de changed the title In memory usage command, key codec is not applied memory usage command, key codec is not applied Jun 26, 2023
@mp911de mp911de added the type: bug A general bug label Jun 26, 2023
@mp911de mp911de changed the title memory usage command, key codec is not applied memory usage command passes key as String instead of using the codec Jun 26, 2023
@mp911de mp911de added this to the 6.2.5.RELEASE milestone Jun 26, 2023
mp911de added a commit that referenced this issue Jul 6, 2023
Previously, we represented the key as plain string without using RedisCodec.
mp911de added a commit that referenced this issue Jul 6, 2023
Previously, we represented the key as plain string without using RedisCodec.
@mp911de mp911de closed this as completed Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants