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

Client-side caching invalidation messages not parsed correctly #3064

Open
tishun opened this issue Nov 29, 2024 · 0 comments
Open

Client-side caching invalidation messages not parsed correctly #3064

tishun opened this issue Nov 29, 2024 · 0 comments
Labels
status: mre-available Minimal Reproducible Example is available type: bug A general bug

Comments

@tishun
Copy link
Collaborator

tishun commented Nov 29, 2024

Bug Report

Based on the problem described in #3050

      private static void issue3050() throws InterruptedException {

        final var client = RedisClient.create(local_standalone);
        client.setOptions(ClientOptions.builder().protocolVersion(ProtocolVersion.RESP2).build());

        final var pubSub = client.connectPubSub();
        final var tracking = TrackingArgs.Builder.enabled().redirect(pubSub.sync().clientId()).bcast();

        final var data = client.connect();

        // prepare our connection and another party
        final var otherParty = client.connect();
        final var commands = otherParty.sync();

        final String[] currentMessage = { null };

        data.sync().clientTracking(tracking);

        pubSub.addListener(new RedisPubSubAdapter<>() {

            @Override
            public void message(String channel, String message) {
                System.out.printf("Channel: %s, Message: %s%n", channel, message);
                currentMessage[0] = message;
            }
        });

        pubSub.sync().subscribe("__redis__:invalidate");

        Map<String, String> mset = new HashMap<>();
        mset.put("foo", "bar");
        mset.put("baz", "qux");
        commands.mset(mset);

        do {
            Thread.sleep(1000);
        } while (currentMessage[0] == null || !currentMessage[0].equalsIgnoreCase("baz"));
    }

Current Behavior

In PubSubOutput we attempt to handle both elements of the message content (3)
The second element always overwrites the first one , as the logic does not handle lists

1) "message"
2) "__redis__:invalidate"
3) 1) "baz"
   2) "foo"

Expected behavior/code

We should harmonize how the same logic works for RESP3 and RESP2 if possible

Environment

  • Lettuce version(s): 6.5.0.RELEASE
  • Redis version: any

Possible Solution

Use RESP3

@tishun tishun added type: bug A general bug status: mre-available Minimal Reproducible Example is available labels Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: mre-available Minimal Reproducible Example is available type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant