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 "__redis__:invalidate" #280
Comments
@zuiderkwast Now might be the best time to reserve some channel namespace for server side purpose. And should we disable external publish on those reserved channels? |
We can add a channel alias now (in the 7.2.4-rc2) if we're really fast. I don't know if it's necessary though. WDYT? Maybe we should call it Forbid push to reserved channels is a breaking change, so that's for 8.0, ok? Can we forbid publish to any channel starting with double underscore? |
Could we have a way just add an alias for this and make the redis:invalidate as deprecated, then after releasing several major release, we could remove it, Thanks |
I think we can go for
|
We discussed reserving a namespace in the past, and the decision was that we shouldn't reserve it because that prevents clients from also sending along that channel. One use case that was mentioned is it allows a single way to do refresh ahead caching. (you can either let the key get deleted, which generates a message, or send a message to it). |
Albeit a breaking change, by reserving channel(s) for server side, we gain few things:
One recommendation could be clients perform a psubscribe on |
Can we move "reserving channel(s)" to a separate issue? For the invalidate messages, I've investigated a little. If one client does This behaviour makes sending to both channels a little more complicated. My suggestion is that we check if the client is subscribed to |
Can you elaborate a bit about the problem of double publishing in this case? I would assume the client will no-op on the messages if it doesn't recognize the channel over which the messages were sent, just like the non-redirection case? |
@PingXie how do you know all clients would do that? Besides, i wouldn't want to send two messages every time. Invalidations can be many and can eat a lot of bandwidth.
Not sure what you mean by this. |
I don't know. I was just comparing the non-redirection case (where the client is getting unsolicited messages) vs the normal case (where the client actively looks for messages). I thought you are saying the double publishing idea works for the normal case but not the unsolicited case? My understanding is IF it works for the normal case, it should work for the unsolicited case as well. But I agree that is a big IF that I don't have a high confidence on either atm.
That's my concern too.
I meant the unsolicited case of |
(If I'm not mistaken) Non-redirection works for RESP3 only and the client gets push messages. They're not unsolicited. Why would they be? |
Where client 8 is in pubsub mode but didn't subscribe to that particular channel... It's a corner case for sure, but it'd ve a breaking change to change it, wouldn't it? (We could consider it a bugfix maybe.) |
I think this code pointer is what you are referring to. My understanding is that a RESP 3 client does not need to be in the pub/sub mode in order for the server to deliver the cache invalidation message but for a RESP 2 client, it needs to be in the pub/sub mode though not required to subscribe to the invalidation channel. Both are "unsolicited" IMO but yes there is more "surprise" in the RESP3 case. Nonetheless, this is probably a digression from your original topic already. I was just trying to get the background picture.
Yes it would've been a breaking change even if we double-publish, since it is hard to speculate the client behavior. I wonder if we should just consider "channel names" part of the extended wire protocol and level them as-is. The RESP protocol is incomplete IMO as it covers the syntax parts only but semantics matter too, as seen in this case. |
Invalidation messages for client-side caching (see CLIENT TRACKING) are sent to the special channel
__redis__:invalidate
.Simply changing it would make Valkey incompatible with Redis OSS 7.2, so we don't want to do it like that. We want to change this channel name in a backward-compatible way:
If the client is subscribed to
__redis__:invalidate
, we send the invalidation messages to this channel and if subscribed to__valkey__:invalidate
we send to that channel.The text was updated successfully, but these errors were encountered: