Streams & policy behaviour in 3.12.2 #10496
-
I am trying to understand how message retention with Streams with 3.12.2. I have a test stream with about a 100+ messages of varying lengths. The policy only seems Scenario 1:
{"vhost":"/","name":"stream-expiry-2","pattern":".*","apply-to":"streams","definition":"{\"max-age\":\"10m\",\"stream-max-segment-size-bytes\": 40960}","priority":0}
Scenario2:
It seems that policies are not a runtime thing but can only be defined at the creation of the stream. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
@zaeemarshad policies absolutely are "a runtime thing" but not everything that can be applied via a policy can be applied retroactively, or sometimes it can be but it won't have an effect on the existing messages. This is the case of several TTL-related features in queues. Moreover, some things in RabbitMQ cannot be changed once set. You cannot change the maximum number of priorities of a queue after defining it. You cannot change a queue type after declaring it, and so on. There is no migration path from one queue type to another at runtime, and there won't be. Moreover, you cannot set every setting to a completely arbitrary value. Streams were not designed to be limited to a single offset of 40 or 50 kiB, that's just not a practical workload for a data structure that can keep its data around for hours, days, and maybe even weeks (if you are certain you won't run out of disk over this time period). See what kind of values the example in the docs uses. I do not understand where in Scenario 2 you remove the policy; you claim to "remove the stream and add messages". Add messages where, since the stream is gone? In any case, just like with queue TTL, this is not a feature you are expected to flip back and forth after the stream has been created and is in operation, in particular changing the the segment size part at runtime does not make much sense. |
Beta Was this translation helpful? Give feedback.
-
A mandatory mention of the fact that 3.12.2 is from July 2023 and is 10 patch releases behind. Not one, not three, ten. |
Beta Was this translation helpful? Give feedback.
-
@zaeemarshad I did some testing that confirms your findings: the policy does not apply automatically after the stream creation. I managed to get the expected behavior (max segment size in my tests) after restarting the stream (with Can you try again with a stream restart? You can use Stream PerfTest to publish messages. |
Beta Was this translation helpful? Give feedback.
-
@zaeemarshad the max-segment-size-bytes configuration is a configuration that will only be picked up at stream declaration time. The fact that it kind of works if you restart the stream after the policy is a bug and this behaviour will be removed so don't rely on this. Updating the retention at runtime is supported however, doesnt require a stream restart and should work fine right now. |
Beta Was this translation helpful? Give feedback.
@zaeemarshad the max-segment-size-bytes configuration is a configuration that will only be picked up at stream declaration time. The fact that it kind of works if you restart the stream after the policy is a bug and this behaviour will be removed so don't rely on this.
Updating the retention at runtime is supported however, doesnt require a stream restart and should work fine right now.