Skip to content

Stream consumers: Re-purpose seen-time, add active-time#11099

Merged
oranagra merged 8 commits intoredis:unstablefrom
guybe7:consumer_last_seen
Nov 30, 2022
Merged

Stream consumers: Re-purpose seen-time, add active-time#11099
oranagra merged 8 commits intoredis:unstablefrom
guybe7:consumer_last_seen

Conversation

@guybe7
Copy link
Collaborator

@guybe7 guybe7 commented Aug 10, 2022

Fix #9996

  1. "Fixed" the current code so that seen-time/idle actually refers to interaction attempts (as documented; breaking change)
  2. Added active-time/inactive to refer to successful interaction (what seen-time/idle used to be)

At first, I tried to avoid changing the behavior of seen-time/idle but then realized that, in this case, the odds are the people read the docs and implemented their code based on the docs (which didn't match the behavior).
For the most part, that would work fine, except that issue #9996 was found.

I was working under the assumption that people relied on the docs, and for the most part, it could have worked well enough. so instead of fixing the docs, as I would usually do, I fixed the code to match the docs in this particular case.

Note that, in case the consumer has never read any entries, the values
for both "active-time" (XINFO FULL) and "inactive" (XINFO CONSUMERS) will
be -1, meaning here that the consumer was never active.

Note that seen/active time is only affected by XREADGROUP / X[AUTO]CLAIM, not
by XPENDING, XINFO, and other "read-only" stream CG commands (always has been,
even before this PR)

Other changes:

  • Another behavioral change (arguably a bugfix) is that XREADGROUP and X[AUTO]CLAIM create the consumer regardless of whether it was able to perform some reading/claiming
  • RDB format change to save the active_time, and set it to the same value of seen_time in old rdb files.

Todo:

  • update docs

Seen-time now represents the last attempted read/claim (somehow breaking change)
Added active-time which represents the last successful read/claim

Seen-time corresponds to "idle" in XINFO CONSUMERS
Active-time corresponds to "inactive" XINFO CONSUMERS

Note that, in case the consumer has never read any entries, the values
for both "active-time" (XINFO FULL) and "inactive" (XINFO CONSUMERS) will
be -1, meaning here that the consumer was never active.

Note that seen/active time are only affected by XREADGROUP/X[AUTO]CLAIM, not
by XPENDING, XINFO and other "read-only" stream CG commands (always has been,
even befoe this PR)

Other changes:
Use the cached time, saving a system call, in many places in t_stream.c
@guybe7
Copy link
Collaborator Author

guybe7 commented Aug 10, 2022

@itamarhaber @oranagra currently we are not saving active_time to RDB.
on the one hand, it's somewhat "runtime" info and should not be persisted.
On the other hand, so is seen_time, which is persisted

@guybe7 guybe7 added the breaking-change This change can potentially break existing application label Aug 14, 2022
Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming we wanna avoid RDB format changes, maybe we wanna re-purpose that field in the RDB to store the active-time (which is what it actually was, right), rather than save the seen time?
also, when loading the rdb, maybe we can load it into both fields?

i.e. we'll be saving the active time (same as we did), but loading it into both.

@oranagra oranagra added the approval-needed Waiting for core team approval to be merged label Oct 6, 2022
@oranagra
Copy link
Member

oranagra commented Oct 6, 2022

@redis/core-team please comment / approve.

@oranagra
Copy link
Member

approved in a core-team meeting.
we concluded that since 7.2 is gonna have rdb format changes anyway (#11290), then we can afford changing the streams rdb format as well.

shall we do that now? or only after the above mentioned PR matures?

@guybe7
Copy link
Collaborator Author

guybe7 commented Oct 18, 2022

@oranagra i guess we should do it now (unless you have a reason to think that #11290 won't be ready before we release 7.2?)

@oranagra
Copy link
Member

IIRC the comments i gave there are quite substantial, so maybe take the safe route and merge change the rdb part in a separate PR after it becomes a reality.

@guybe7
Copy link
Collaborator Author

guybe7 commented Oct 18, 2022

@oranagra we can but:

  1. blame log will be slightly uglier
  2. we need to make sure to remember (open an issue under the 7.2 project?)

@oranagra
Copy link
Member

i don't think the damage in the blame log is high, just a couple of comments to delete.
plus the fact that the rdb change is added in a different commit than the one added the feature.

on the other hand, maybe there's also no harm in keeping this PR open for much longer.. there's nothing that depends on it, and i don't think it'll accumulate any conflicts.

@oranagra
Copy link
Member

oranagra commented Nov 9, 2022

@guybe7 the RDB version was incremented, so you can now update this PR

@oranagra oranagra added release-notes indication that this issue needs to be mentioned in the release notes and removed approval-needed Waiting for core team approval to be merged labels Nov 20, 2022
@guybe7
Copy link
Collaborator Author

guybe7 commented Nov 30, 2022

@oranagra fixed RDB stuff, please have a look

Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any new tests we wanna have around rdb loading (to specifically test the feature of this PR)?

regardless, i was about to say that this change is trivial and there's no need to add a compatibility test for the previous type, but i guess you proved me wrong, so let's do that.
have a look stream_cgroups.tcl, there's a test using RESTORE, we can do the same.

enjoy-binbin added a commit to enjoy-binbin/redis that referenced this pull request Dec 1, 2022
The test failed with `ERR DUMP payload version or checksum are wrong.`
And it only fails on CentOS, i guess this payload is not suitable on
CentOS.

Payload regenerated using string2printable, introduced in redis#11099
madolson pushed a commit to madolson/redis that referenced this pull request Apr 19, 2023
1. "Fixed" the current code so that seen-time/idle actually refers to interaction
  attempts (as documented; breaking change)
2. Added active-time/inactive to refer to successful interaction (what
  seen-time/idle used to be)

At first, I tried to avoid changing the behavior of seen-time/idle but then realized
that, in this case, the odds are the people read the docs and implemented their
code based on the docs (which didn't match the behavior).
For the most part, that would work fine, except that issue redis#9996 was found.

I was working under the assumption that people relied on the docs, and for
the most part, it could have worked well enough. so instead of fixing the docs,
as I would usually do, I fixed the code to match the docs in this particular case.

Note that, in case the consumer has never read any entries, the values
for both "active-time" (XINFO FULL) and "inactive" (XINFO CONSUMERS) will
be -1, meaning here that the consumer was never active.

Note that seen/active time is only affected by XREADGROUP / X[AUTO]CLAIM, not
by XPENDING, XINFO, and other "read-only" stream CG commands (always has been,
even before this PR)

Other changes:
* Another behavioral change (arguably a bugfix) is that XREADGROUP and X[AUTO]CLAIM
  create the consumer regardless of whether it was able to perform some reading/claiming
* RDB format change to save the `active_time`, and set it to the same value of `seen_time` in old rdb files.
enjoy-binbin pushed a commit to enjoy-binbin/redis that referenced this pull request Jul 31, 2023
1. "Fixed" the current code so that seen-time/idle actually refers to interaction
  attempts (as documented; breaking change)
2. Added active-time/inactive to refer to successful interaction (what
  seen-time/idle used to be)

At first, I tried to avoid changing the behavior of seen-time/idle but then realized
that, in this case, the odds are the people read the docs and implemented their
code based on the docs (which didn't match the behavior).
For the most part, that would work fine, except that issue redis#9996 was found.

I was working under the assumption that people relied on the docs, and for
the most part, it could have worked well enough. so instead of fixing the docs,
as I would usually do, I fixed the code to match the docs in this particular case.

Note that, in case the consumer has never read any entries, the values
for both "active-time" (XINFO FULL) and "inactive" (XINFO CONSUMERS) will
be -1, meaning here that the consumer was never active.

Note that seen/active time is only affected by XREADGROUP / X[AUTO]CLAIM, not
by XPENDING, XINFO, and other "read-only" stream CG commands (always has been,
even before this PR)

Other changes:
* Another behavioral change (arguably a bugfix) is that XREADGROUP and X[AUTO]CLAIM
  create the consumer regardless of whether it was able to perform some reading/claiming
* RDB format change to save the `active_time`, and set it to the same value of `seen_time` in old rdb files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change This change can potentially break existing application release-notes indication that this issue needs to be mentioned in the release notes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] XREADGROUP with no results does not reset XINFO CONSUMERS idle timer

5 participants