Client tracking in lua scripts with computed keys?

56 views
Skip to first unread message

m...@xecycle.info

unread,
Dec 25, 2020, 9:22:13 AM12/25/20
to redi...@googlegroups.com
Hello list,

Playing with scripts and client tracking (no bcast mode), it seems invalidate messages are generated only if the relevant key is given in KEYS, not if in ARGS or as a literal in the script; I wonder if that’s intentional?  I’m trying to implement a use case that looks like “set prefix.a.$(incr counter) value; get prefix.b.$(get counter)” and hoping to get notifications for prefix.b.123.  Of course the client cannot know the value of counter to populate KEYS table; if I separate this into two steps then it really doubles round-trip time because of the data dependency on value of counter.  Can I configure redis to enable tracking on whatever keys actually touched by scripts?

Madelyn Olson

unread,
Dec 25, 2020, 12:11:55 PM12/25/20
to redi...@googlegroups.com
Hey,

The short answer to your question is no. Server assisted tracking will only track the keys which are pre-declared for a Lua script.

The long answer for why this happens is that client tracking doesn’t watch which keys were accessed, but instead looks at which keys the command is supposed to access. This functionality was built out for cluster mode. With LUA, Redis can’t introspect into the script and know what keys will be accessed ahead of time, so it has to rely on which keys you declared it to touch. If you think this is a feature that is missing, you should open an issue and request it. It would be a pretty heavy rewrite of the way client tracking works, but it could be worth it.

-Madelyn
On Dec 25, 2020, 6:22 AM -0800, m...@xecycle.info <m...@xecycle.info>, wrote:
Hello list,

Playing with scripts and client tracking (no bcast mode), it seems invalidate messages are generated only if the relevant key is given in KEYS, not if in ARGS or as a literal in the script; I wonder if that’s intentional?  I’m trying to implement a use case that looks like “set prefix.a.$(incr counter) value; get prefix.b.$(get counter)” and hoping to get notifications for prefix.b.123.  Of course the client cannot know the value of counter to populate KEYS table; if I separate this into two steps then it really doubles round-trip time because of the data dependency on value of counter.  Can I configure redis to enable tracking on whatever keys actually touched by scripts?

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/5fe54a56.1c69fb81.e455e.b9c7SMTPIN_ADDED_BROKEN%40gmr-mx.google.com.
Reply all
Reply to author
Forward
0 new messages