Conversation
|
@yossigo Even if we hold off on this PR you may want to commit this tiny fix |
|
@michael-grunder first of all, thanks! i didn't look at the code yet, but i have one concern about the update of hiredis in deps. |
|
redis-cli code looks good to me. certainly enough as a starting point for future improvements. i think push messages should be displayed by default. considering this tool is mainly for human eyes, not scripts. and considering they'll most likely be absent for any existing scripts that use redis-cli but are probably not using pubsub / invalidations. |
deps/update-hiredis.sh
Outdated
There was a problem hiding this comment.
@michael-grunder @oranagra perhaps we should consider using git subtree to manage this dependency?
src/redis-cli.c
Outdated
There was a problem hiding this comment.
@michael-grunder I think printing this by default makes sense for TTY mode.
There was a problem hiding this comment.
OK, I'll make the change. I suppose what I'll do is change the option to something like --push-replies and allow for always, tty, and never (with the default being tty). That way there's a fair amount of control with a sane default.
|
OK reworked to display PUSH messages by default if we detect STDOUT is a tty and changed the configuration argument to a boolean I'll switch to using a subtree for the hiredis dependency if everyone is good with that. Edit: I rebased the changes with hiredis as a subtree in a second branch on my fork. Should make it easy to pick the subtree or non-subtree upgrade 😄 |
git-subtree-dir: deps/hiredis git-subtree-split: 39de5267c092859b4cab4bdf79081e9634b70e39
|
@michael-grunder I see the subtree changes are already on this PR. I have done some reading and it looks like subtrees are really a good fit to handle the deps and deps updates, but I haven't had the chance to experience with them. Do you have any take on this? @oranagra any thoughts? I lean towards adopting this for hiredis, and if we're happy with it expand to other deps. |
|
Ahh, I was going to hold off pushing the subtree commits in this PR branch until we decided which was preferable but then I noticed the fix I needed to do in 890ff61. I'm happy either way. I haven't really used subtree much but it does seem like a nice way to manage deps |
|
I don't mind using git subtree, IIUC with the exception of the commit comments, the result is the same as just coping the files. (am I wrong?) |
|
It looks like hiredis was last updated in Redis in b087dd1, which appears to be hiredis 01535274 As far as I can tell, they're identical: Super quick and dirty bash git clone https://github.com/redis/redis.git
cd redis && git checkout b087dd1db60ed23d9e59304deb0b1599437f6e23 && cd deps
git clone https://github.com/redis/hiredis hiredis-upstream && \
cd hiredis-upstream && git checkout 01535274441bf235dc17ace1343515755a6049ed
cd .. && diff hiredis hiredis-upstreamMy diff just shows Edit: I suppose we could choose to use the new allocator replacement feature of hireds v1.0.0 but I don't think it's really needed and I always prefer caution. Edit2: There is another relevant change that actually went from Redis 2647084, 5e399d5 to hiredis 5c9f49e2 TL;DR: As far as I can tell there isn't any specific hiredis logic that differs between the two repos. That being said, I'm not in any rush; Better to be careful with such a big merge. Going forward coordination should be simpler. |
|
Sorry I was running out the door. I'll go through the whole diff between hiredis/1.0.0 and Redis/unstable and see if there's anything there that I don't recognize. |
|
Had a quick look at this, seems good to me. Because commits were not done consistently to redis/hiredis, the current redis unstable version doesn't correspond to any single hiredis version. Comparing the tree, it turns it resembles d952ed877ab1e515fcf5d16ec69576b87be61796 most and everything in it was later merged. @michael-grunder I will be happy to get your OK as well. |
|
@yossigo That looks right to me, thanks for taking a look. It looks like we're still using |
Add logic to redis-cli to display RESP3 PUSH messages when we detect STDOUT is a tty, with an optional command-line argument to override the default behavior. The new argument: --show-pushes <yn> Examples: $ redis-cli -3 --show-pushes no $ echo "client tracking on\nget k1\nset k1 v1"| redis-cli -3 --show-pushes y
890ff61 to
81879bc
Compare
|
looks like the merge broke the sentinel tests (although not consistently): @michael-grunder can you look into it? p.s. while bisecting i noticed that the Makefile fails to detect the change. |
|
Sure, I'll take a look. |
|
This was a fun one to track down. The offending commit appears to be this sdsrange overflow fix. Specifically, it's the -void sdsrange(sds s, int start, int end) {
+int sdsrange(sds s, ssize_t start, ssize_t end) {Redis' void sdsrange(sds s, ssize_t start, ssize_t end);What's happening is that hiredis ends up executing Redis' copy of I can fix the problem by wrapping my calls to Link to my branch with a quick and dirty fix. I'm happy to implement and formalize a proper fix once we determine how best to tackle the issue. |
|
We had this in the past (when i changed the sds header to support various length classes). So in this case, maybe the quick fix is actually to mirror this change to redis (seems that it should be safe), but that still leaves the possibility of this biting us again in the future. Taking the other alternative you suggested (which is to rename all the sds interfaces would mess up tons of source lines and the blame log, so i wish we can find another safe way. p.s. we also faced similar problem in RL with other tools that use both hiredis and (lib)redis, the solution there is to build a dynamic library using @yossigo do you have any other ideas or thoughts? |
|
Because hiredis has really minimal use of sds, I think wrapping the symbols makes most sense to me. @oranagra why do you think it will be that much of a change? |
|
@yossigo what do you mean by wrapping the symbols? same thing that's already one in the quick and dirty fix? I don't know the hiredis code that well, i was referring to replacing all symbol names from |
|
@oranagra yes. As @michael-grunder indicated it's not used that extensively. Being a static library (and IMHO it should remain so), we don't really have other options. Even if we pull the specific prototype change into Redis, fundamentally the problem is still there and may arise again in the future with other unexpected changes. |
|
I don't mind doing it but just so everyone is on the same page. Are we settled on updating all Another possibility might be to detect when hiredis is being built within Redis' build tree and use/include Redis' copy of sds. That option would take more doing though. |
|
@michael-grunder I think trying to detect the fact that hiredis is part of Redis may not be good enough, because such collisions could surface indirectly (e.g. a module that uses hiredis and gets loaded into Redis). The simplest and safest option would be to use private symbols for the embedded sds to avoid any risk of collisions. It's a ugly hack but the safest. Another option is to create an "amalgamated" static-inlined version of sds, which will eliminate the impact on the rest of the hiredis code base. |
|
A quick attempt at the amalgamation option: Used |
|
I implemented the changes we discussed above and pushed them to a branch on my fork of Redis As you can see I renamed I ran tests both with and without valgrind and everything seems good. I don't always see success running the sentinel tests locally but they fail the same way in this branch and from a commit before any of these changes were merged. I'll open a PR if this is the way we want to solve the issue. |
Add redis-cli RESP3 Push support
|
Ohh, seeing the comment in redis-cli: +#include <sds.h> /* use sds.h from hiredis, so that only one set of sds functions will be present in the binary */i now realize that i attempted to resolve this problem permanently in f15df8b (rather than copy the changes i made to sds into hiredis as i said a 2 days ago). So the problem is only with Sentinel. p.s. maybe you wanna use it in hiredis to avoid the mass renaming you did there. (though that would mess up readability and also the 'go to definition' of IDEs. |
|
Works for me. I need to take a closer look but I should be able to just upgrade hiredis to use Redis' sds and then wrap I'm not sure whether I can release that in Hiredis before a major version, but it should be acceptable to use it for the one Redis bundles. I'll put it together in the morning. |
|
@michael-grunder i lost you. why do you need to update hiredis or wrap sdsrange? or where you referring to my note that said:
|
|
No, I misunderstood what you were suggesting. I thought you were suggesting simply changing Here's a branch with your suggestion It's not a solution though, because because redis-cli.c directly interacts with Edit: I may be able to fix this by overriding Hiredis' allocators to use zmalloc, etc. Edit2: Overriding hiredis' allocators in redis-cli gets all the tests passing. This is a bit dangerous because Redis is directly interacting with |
|
I didn't consider that redis-cli actually calls it's sds functions on pointers allocated by hiredis's sds. that's too dangerous (even if currently working). i guess we should revert to your previous solution, the one in this branch. So since redis-cli actually messes with the sds pointers, it'll have just one sds implementation in it (the hiredis one). Is there anything stopping us from using the redis-cli approach in sentinel too? (would possibly be safer). Since we probably explored all the options, it's probably time to make a PR. |
|
I feel bad this was such a painful update. I'm happy to open a PR with this solution as you suggested, but I wonder if there's actually a cleaner option. If you look at the modifications to the SDS library that we've done in Hiredis you'll see that most of them have to do with checking for NULL returns from allocations. This is so we can gracefully handle OOM. That's not required in Redis since (unless this has changed) Redis just SIGABORTs on OOM. The sdsrange overflow fix seems low priority since it's not currently in Redis and has never caused a problem. Even if it did occur, it's only likey to cause issues for redis-cli or redis-benchmark (non critical). TL;DR: What about just patching hiredis to use Redis' current SDS for the one bundled with Redis? |
|
I don't mind improving the sds code in Redis to handle failed allocation (although as you said, it's dead code in Redis), but doing that, same as forcing the sds code in hiredis to be identical to redis', is just hiding the problem. |
|
Btw, i suppose that if we take that path (only one set of symbols in each process), maybe we can abandon the mass rename and the compatibility header you created? |
|
I can avoid the mass renaming, and use Hiredis' SDS library in sentinel but that will require me to match versions (e.g. hiredis v1.0.0 doesn't have Also since I maintain hiredis I can make sure this mismatch isn't a problem in the future. Let me know what you prefer and I'll open a PR (and then we can forget about this whole ordeal 😄) |
|
Ohh, silly me. For a moment I forgot that sentinel is actually redis. |
Bullet points:
RESP3push messages in redis-cli (e.g.SUBSCRIBE/client tracking messages)--print-push-msgsto display the messages (maybe this should be the default for invalidations?)I'm happy to rework how invalidations are displayed but it seemed reasonable to use a special format (like redirections) for that when in normal mode, but output in csv/raw when requested.
Here's how it looks: