-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
django-redis is incompatible with redis-py >= 3 #342
Comments
I'm presuming adding support for redis-py v3 will end up being a breaking change? If so, would it be worth creating a new django-redis point release (eg |
To add info here:
This is where things go sideways: We need to return a string not the CacheKey object anymore. Redis doesn't cast to string anymore. |
Not necessarily. All functions that pass those keys to redis-py could also convert CacheKeys to strings. That would retain the intention behind CacheKeys. (Of couse it's more work, introduces duplicate code and error prone if test coverage is not sufficient enough.) But it's for @niwinz to decide which way to go. |
Alternative fix: Update the lose constraint in requirements. install_requires=[
"Django>=1.11",
"redis>=2.10.0,<3",
], |
The pinning suggestion has a PR #343. |
My production service failed by that. I added |
This is a stopgap for a compatibility issue relating to a dependency of a dependency (redis-py, which is a requirement of django-redis). See: jazzband/django-redis#342
Yeah, got bitten by this when installing django-redis via pip. |
I have created PR #344 which adds support for redis-py 3.0.0 to django-redis and is backwards compatible withe redis-py 2.10.0. |
It would still be nice to have a new version with just the version constraint using redis-py 2.x and then apply a fix and version for upgrading to 3.x. |
Why? The fix is fully backwards compatible. What is the downside? |
If you have other dependencies relying on redis-py 2.x in the same environment, that will break things unnecessarily. BUT I guess it's not a huge deal because I can also lock the dependency locally. |
Assuming that environment has declared its dependencies, the PR keeps the same lower redis-py version bound (2.10.0) and is fully compatible with redis-py 2.x. Therefore, it is compatible in an environment otherwise constrained to redis-py 2.x. I believe that addresses that use case. Pip is smart enough to get the version that satisfies all declared version ranges. Or are you saying this environment relies on on django-redis to get the dependencies for other unrelated packages? IMO, those other packages should be fixed to properly declare their supported dependency ranges. |
I jumped on the gun too fast not properly looking at the PR. |
@jdufresne While I think thats a valid point, I think its unreasonable, not to mention I'd never be able to look at the output of In short, I do rely on django-redis to properly declare its dependencies. Same as I do for any other package manager, even that |
@awbacker The PR to add redis 3.0.0 support does correctly declare the redis-py dependencies as |
To avoid this problem in future, with #344 would we also want to lock the redis-py version to |
- django-redis CacheKey is incompatible with redis-py 3, see jazzband/django-redis#342
Depends on the definition of “this problem”. For us “this problem” is that we cannot upgrade our production environment to redis-py 3 at the moment (without switching away from the stable releases of django-redis). You cannot assume that the breaking changes in a future redis-py 4 will break django-redis. Introducing an upper bound without need would prevent¹ us to upgrade to redis-py 4 in any case. Therefore “this problem” would not have been avoided. If for you “this problem” is, that something broke because redis-py was not pinned, I recommend pinning all your requirements recursively. To keep track of what your explicit requirements are, you can use pipenv or one of its competitors. If you do not want pipenv to install your requirements, you can still use it to manage them and generate a requirements.txt for you based on a Pipfile. If even this nor one of pipenv's competitors work for you, consider this workflow: https://www.kennethreitz.org/essays/a-better-pip-workflow ¹ Yes, pip install ignores the upper bound if I specify |
Greetings, @michael-k
Let's say I am using
Now, if I would do
As far as I understand, sub-dependencies in Pipenv are managed by a smart dependency resolution and by locking process with a lock-file, which is being created, based on each core (1st level) dependency. And their sub-dependencies are being managed automatically by given version ranges (as you can see by I am not quite sure, that I got the proposal of putting all dependencies and sub-dependencies in Pipfile This, in my opinion, is a wrong approach and I agree with @czlee that we have a problem. If you can point me to what I am missing, would be great. |
Any ETA for this to be solved? This is causing major problems. |
I'm having the same issue here, using django-redis |
Sure.
In cases 1 and 2 you are touching your requirements anyway and should be able to pin redis-py yourself. In case 3 you're safe. In case 4 you're safe if you used the “right” tooling.
Yes, it would not. But a version range of If such an incompatibility is known and no fix is available, releasing a new version with an upper bound is a good first solution. But not based on some assumption about the future. |
In the compatibility PR, I've included redis-py master branch in the test matrix. This should hep catch these situations earlier in the future. Unfortunately, the downside is the Travis run time is now around 25 minutes. |
I see the points, thanks @michael-k It is true, the current version of So, with the next major redis release (meaning it will have something breaking), we can expect again the same disruption and complaints from the people. The only difference in two behaviors - fewer people will complain. :) Anyway, thank you for the fast reaction and fixes and reasoned discussion! 👍 |
Thank you very much for the discusion. Personally i dont consider that a problem (the fact that a new version of redis is released and that causes a major problems), in this case, just pin redis to a specific version on your projects. Yes you are right, on new installations it will be broken, but we are talking on new instalations? or existing problems? I think that existing codebase and production projects are more important and they can be workarounded very easy: pin a concrete version of redis (in fact it should be done from day 1 in a real production ready project, because you need to have a deterministical installs; at least is my recomendation, so if you have transitive dependencies that are not fixed/pinned on you project, try to do it, this will avoid many similar problems). Now, the redis part is merged, and 4.10.0 is released. Also 4.9.1 is released with the pinned redis version for people that does not wants upgrade to 4.10.0 right now. 4.10.0 has some tests issues related to touch method, so if you have plans to use it, take cara that maybe that part my have some bugs, and will be fixed soon (and a new bugfix release will be issued). And again. Thanks! And special thanks to @jdufresne for the PR ❤️ |
I get random errors on my local docker setup if I use the site and constant errors for things like POST and api calls. For example: ``` web_1 | redis.exceptions.DataError: Invalid input of type: 'CacheKey'. Convert to a byte, string or number first. ``` Details of this issue are here: jazzband/django-redis#342 The latest djang-redis release fixes the issues.
Included the MySQL PGP signature to avoid randomly timing out when looking it up on pgp-mit-edu. Locked down the redis version to work around the problem described in jazzband/django-redis#342
Error is: "DataError: Invalid input of type: 'CacheKey'. Convert to a byte, string or number first." (Fix and workaround in this issue: jazzband/django-redis#342)
From the redis-py release notes:
See https://github.com/andymccurdy/redis-py/blob/9b03af26dc829beea232a3248768de933f4c3b67/CHANGES#L9-L15
The
CacheKey
class used by django-redis is no longer supported.I'm happy to open a PR, but I wanted to ask first if it's better to drop
CacheKey
or to cast keys to strings right before sending them to redis-py? The latter would be more work, but retain the intended use ofCacheKey
:The text was updated successfully, but these errors were encountered: