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

PublishEvent option failed to set keys TTL #385

Open
MrGuoRanDuo opened this issue Mar 30, 2023 · 5 comments
Open

PublishEvent option failed to set keys TTL #385

MrGuoRanDuo opened this issue Mar 30, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@MrGuoRanDuo
Copy link

MrGuoRanDuo commented Mar 30, 2023

Describe the bug
In use the PublishEvent function , I set the PublishEventOption :
client.PublishEventWithMetadata(map[string]string{"ttlInseconds":"3600"})
But when I check redis :
127.0.0.1:6379> TTL Stop
(integer) -1
clearly failed to set ttl , the value is -1 , but key store success.
And I don't see anything ttl unit test in client/pubsub_test.go

To Reproduce
redis docker version 6.2.5
go version 1.19
github.com/dapr/dapr v1.10.4
github.com/dapr/go-sdk v1.7.0

Hear's full codes:
if err := d.daprClient.PublishEvent(ctx, "redis-pubsub", master.MethodType_Stop.String(), param, client.PublishEventWithMetadata(map[string]string{"ttlInseconds": "3600"})); err != nil { return err }

Expected behavior

  1. If this is user mistake, please point where I was wrong.
  2. fix this bug, pls
@MrGuoRanDuo MrGuoRanDuo added the bug Something isn't working label Mar 30, 2023
@Taction
Copy link
Member

Taction commented Apr 1, 2023

For those components that don't have built-in ttl support, dapr will handle it in runtime. This means dapr will check the TTL and ignore these expired messages.

@MrGuoRanDuo
Copy link
Author

@Taction Thx for your reply
In this case, Redis store too much msg , i have to delete them manually(because I lost one msg, may cause by redis perforemance issue).
My question :Msgs are not delete after they are receviced(OnTopicEvent), is that right?

@Taction
Copy link
Member

Taction commented Apr 3, 2023

My question :Msgs are not delete after they are receviced(OnTopicEvent), is that right?
Yes, Dapr redis pubsub component uses redis stream which doesn't delete messages when acked.

For your situation, you can set maxLenApprox metadata, which defines maximum number of items inside a stream. The old entries are automatically evicted when the specified length is reached so that the stream will be left at a constant size. Or you can try other components (such as rabbitmq), which delete the expired or acked message.

@wXwcoder
Copy link
Contributor

wXwcoder commented May 4, 2023

Describe the bug In use the PublishEvent function , I set the PublishEventOption : client.PublishEventWithMetadata(map[string]string{"ttlInseconds":"3600"}) But when I check redis : 127.0.0.1:6379> TTL Stop (integer) -1 clearly failed to set ttl , the value is -1 , but key store success. And I don't see anything ttl unit test in client/pubsub_test.go

To Reproduce redis docker version 6.2.5 go version 1.19 github.com/dapr/dapr v1.10.4 github.com/dapr/go-sdk v1.7.0

Hear's full codes: if err := d.daprClient.PublishEvent(ctx, "redis-pubsub", master.MethodType_Stop.String(), param, client.PublishEventWithMetadata(map[string]string{"ttlInseconds": "3600"})); err != nil { return err }

Expected behavior

  1. If this is user mistake, please point where I was wrong.
  2. fix this bug, pls

Try modifying ttlInseconds to ttlInSeconds

@zarkodam
Copy link

I have the same problem with C# client, when using pubsub with Redis streams:

var metadata = new Dictionary<string, string>
{
{"ttlInSeconds", "120"}
};

        await _daprClient.PublishEventAsync(
            pubsubName: "pubsub",
            topicName: "test",
            data: message,
            metadata: metadata, 
            cancellationToken: cancellationToken);

but when I'm using state store with Redis it works well:

await _daprClient.SaveStateAsync("statestore", "test", 1, metadata: metadata);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants