fix: Recreate group in case redis flush#2656
fix: Recreate group in case redis flush#2656pbonneaudiabolocom wants to merge 2 commits intoag2ai:mainfrom
Conversation
|
I added all the casting to pass the linter. Also, I discivered that this part is not tested at all. (if I insert an exit in that part of the code the tests are running fine. If you have some test example, I would imagine something such as: create stream with group |
| ) | ||
| except ResponseError as e: | ||
| if "NOGROUP" in str(e): | ||
| await self._create_group() |
There was a problem hiding this comment.
Should we change current last_id read position at stream recreation?
There was a problem hiding this comment.
indeed we should. The group being reseted, next id should retart from scratch.
I added some tests as well to be sure it was working better
befd241 to
b70b55f
Compare
|
My code is entering into conflict with the one from 9998c58 I have no idea what the fix on autoclaim is, so it's very hard to understand how to mix it with my code and see what should happen. May you help please ? @JonathanSerafini |
There was a problem hiding this comment.
not sure if this was intended, but your redis PR also includes this change and an unrelated package version change.
| ..., | ||
| ], | ||
| ]: | ||
| async def read_from_group() -> tuple[ |
There was a problem hiding this comment.
i'm thinking at this point you may as well just make def read an async function and do without the nested read_from_group it may make things more readable ?
There was a problem hiding this comment.
this type annotation is likely the first conflict, you can use ReadResponse as a replacement
There was a problem hiding this comment.
the other conflict probably stems from the fact that there are now 2 stream group readers in this code now, one for xreadgroup and another for xautoclaim ... i would assuming that if you want to re-create the group for the former you may also want for the latter.
for the xautoclaim handling, i would just start over from 0-0 i.e the first position and it should be able to take it from there.
b70b55f to
cad2597
Compare
|
Thanks for you feedback. Thanks to it, I decided to crete a specific function that has to protect any provided method against group removal. I updated the code accordingly. Tests are passing. I still have the collowing linter error, but I don't know how to make them disapeer. I'm totally lost in the return typing used to be honnest. Any idea on how to correct that ? |
|
@JonathanSerafini Would you think it' possible to merge it ? Last time it was working fine, but the more the system progress, the more I have to redo the job... |
|
@pbonneaudiabolocom I'm not the right one to ask, i'm not a maintainer or affiliated with this project. That being said re:typing, you have to account for the changes you're making. You've created To account for different input functions you might want to look at how to type a 'parametrized decorator'. |
182cf0b to
c10161b
Compare
- adding a test - reset properly the id - adding another rare case when group is tempered by another system, and IDs gets desynchronized. (AI recommendation) - fixing group creation in autoclaim + get_one message and iter.
- adding a test - reset properly the id - adding another rare case when group is tempered by another system, and IDs gets desynchronized. (AI recommendation) - fixing group creation in autoclaim + get_one message and iter.
|
Hi, I updated my code to fit the different updates. I'm struggling with typing with mypy validation. Honnestly, I have no idea on how to resolve the warning given. I'm far from being at that level of expertise in typing. help would be welcome. |
|
I believe the current implementation deviates from the framework's standards. While FastStream supports creating queues on startup (primarily for development convenience), it shouldn't be responsible for managing production infrastructure at runtime. Recreating the stream on the fly effectively hides the underlying infrastructure issue. The only correct approach here is to fail fast and raise an error indicating that the Redis stream no longer exists. This ensures the service stops predictably, triggering monitoring alerts so we can investigate the incident properly. Also, it would be great if you could revert uv.lock |
|
Hi, For me, whenever a system creates something, it is accountable for it. Then there is 2 solutions:
I'm not against the 2nd approach, but the question then would be, how can we ensure in case a stream is dead that the application will be able to recover somehow. It would be appreciable to raise an exception and to allow the user to capture it somehow and to call the group creation back if it's what is desired.
What I would like to avoid is a group creation done in a separate function, ending up with 2 ways to create group, one in faststream and the othr one in the backup system... more likely to create intrical issues on production. I could adapt the PR to fit that other approach if you want. Best regards, |
Description
When using redis with group, if a flush is done by another parties or the stream is destroyed, faststream enter in an infinite loop, trying to get the next element but not finding the expected group.
Fixes #2611
Type of change
Please delete options that are not relevant.
Checklist
just lintshows no errors)just test-coveragejust static-analysis