Skip to content

add minId overloads #2842

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kijanawoodard
Copy link

@kijanawoodard kijanawoodard commented Jan 21, 2025

Fixes #1718

Initial commit. Still orienting on how to contribute.
It's building. Tests pass.

Before I continue, does the diff look sane?

I think I got the "public api" situated correctly.

The strangest thing I ran into was this error about default parameters. I'm not sure if this is pushing me towards adding a new method rather than an overload, e.g. StreamTrimWithMinId. I took out the default CommandFlags to build successfully.

error RS0026: Symbol 'StreamTrim' violates the backcompat requirement: 'Do not add multiple overloads with optional parameters'

I'm having trouble running the tests locally. I tried running the tests before making any changes and ~2/3 passed. It might be because I don't have all the versions of .net installed.

clarify doc comment

i now think the XTRIM documentation is saying that an entry at exactly MINID is kept.
https://redis.io/docs/latest/commands/xtrim/
forgot to update the length check.
@kijanawoodard
Copy link
Author

I can't tell what's wrong in the appveyor build. It says zero tests failed, but still errors.

@kijanawoodard
Copy link
Author

kijanawoodard commented Jan 22, 2025

I was able to get devcontainer working on WSL enough to build, but the tests can't connect to redis in the devcontainer.

I'll post my changes in case anyone else can follow the breadcrumbs.

I needed to enable Ubuntu integration in docker desktop
image

I added dotnet 8 installation to the Dockerfile under .devcontainer
RUN curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 8.0 --install-dir /usr/share/dotnet/

@kijanawoodard
Copy link
Author

I wasn't able to get dev containers running. The dockerfile in .devcontainer refers to a Dockerfile in tests/RedisConfigs that doesn't exist. I tried using the other ones, but they appear to depend on the docker-compose.yml file in the tests/RedisConfigs folder.

I was able to run the tests with only one failure: FailoverTests.SubscriptionsSurviveConnectionFailureAsync(RESP2) [FAIL]

I got that far by cloning the project in wsl2, running docker compose up in tests/RedisConfigs and then running dotnet test StackExchange.Redis.sln from the project root.

@kijanawoodard
Copy link
Author

kijanawoodard commented Jan 22, 2025

I was wrong about appveyor having no test failures. There were 3 failures that don't seem to be related to my changes here. All 3 timed out running more than 5000ms. If there are known test issues, let me know.

@kijanawoodard
Copy link
Author

I tried pushing an empty commit to rebuild appveyor. The error moved.

ConnectingFailDetectionTests.ConnectIncludesSubscriber(RESP2) [FAIL]

Now there's just that one.

@kijanawoodard
Copy link
Author

@NickCraver @mgravell sorry to @ you guys, but I want to make sure I haven't missed some step in the PR process. I looked for a contributing doc, but didn't see one. Is there anything else I need to do at the moment, or is it fine to just let this PR sit tight?

@WeihanLi
Copy link
Contributor

There's a failed test case, but think it's not related to the changes
image

Maybe add an entry for the release note

https://github.com/StackExchange/StackExchange.Redis/blob/main/docs/ReleaseNotes.md

@kijanawoodard
Copy link
Author

@WeihanLi Yes. The test failures aren't related to the changes I met. All the open PRs are failing tests. I spent some time trying to run the pipeline multiple times but couldn't get a clean run here. The error shifts around on each run.

I was looking for some list of PR procedures to see if I didn't follow a step. I'm happy to do whatever to get merged, but I don't want to randomly do stuff hoping to get noticed.

@mgravell
Copy link
Collaborator

Sorry, looking.

Two immediate thoughts:

  • the API shape gets tricky, because there is an inherent ambiguity since RedisValue is convertable from int; I wonder whether an explicit API name might be preferable, for example StreamTrimByMinId
  • I'm a little unclear as to how the optional ~ and limit work with minid; I'd need to play in a REPL, but the docs suggest they are valid additions

@kijanawoodard
Copy link
Author

kijanawoodard commented Jun 10, 2025

It doesn't seem like ~ makes sense with minid. The docs are ambiguous on whether limit is valid, so I tried it out in redis insight's cli and got "ERR syntax error, LIMIT cannot be used without the special ~ option"

cmd: xtrim my-stream minid 1749592060847-0 LIMIT 3

I then tried
xtrim my-stream minid ~ 1749592086284-0 LIMIT 3, where 1749592086284-0 is the second stream entry id of 2 entries, the command returned (integer) 0 and nothing was removed. I kind of wish it would error instead, but ok.

For completeness, I ran xtrim my-stream minid 1749592086284-0 which returned (integer) 1 as expected.

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.

Add support for stream XTRIM MINID command
3 participants