Skip to content
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

Fix empty result from xread_options with deleted entries #712

Merged
merged 3 commits into from
Dec 19, 2022

Conversation

Quiwin
Copy link
Contributor

@Quiwin Quiwin commented Nov 8, 2022

Hello!

xread_options seems to not handle correctly case when a pending message is deleted.

In my understanding, if a pending message is deleted, its id should still be returned https://redis.io/commands/xreadgroup/#what-happens-when-a-pending-message-is-deleted

This is useful for acknowledging them and cleaning the PEL if some messages could not be processed.

Expected vs actual result

The expected result from the test case is:

&result_deleted_entry = StreamReadReply {
    keys: [
        StreamKey {
            key: "k1",
            ids: [
                StreamId {
                    id: "1666711514590-0",
                    map: {},
                },
            ],
        },
    ],
}

On redis-rs 0.20.2:

&result_deleted_entry = StreamReadReply {
    keys: [
        StreamKey {
            key: "k1",
            ids: [],
        },
    ],
}

On main an Err is thrown:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Response was of incompatible type: "Response type not hashmap compatible" (response was nil)', redis/tests/test_streams.rs:393:10

This is fixed by converting a nil value from redis when casting as an hash into a empty hash.

I am open to better solutions/suggestions!

@Quiwin Quiwin marked this pull request as ready for review November 8, 2022 14:00
@Quiwin Quiwin changed the title Fix/nil hash value Fix empty result from xread_options with deleted entries Nov 8, 2022
@djc
Copy link
Contributor

djc commented Nov 8, 2022

I'm confused why you mention version 0.20.2. Is this a regression, or were you just using a really old version before?

@Quiwin
Copy link
Contributor Author

Quiwin commented Nov 8, 2022

We were using a old version but the issue is also present on main.

@jaymell jaymell requested a review from djc December 18, 2022 20:26
@djc djc merged commit 296f8a6 into redis-rs:main Dec 19, 2022
@jaymell
Copy link
Contributor

jaymell commented Dec 20, 2022

Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants