-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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 incorrect lag and entries-read value with tombstone #13379
Open
artikell
wants to merge
4
commits into
redis:unstable
Choose a base branch
from
artikell:fix_stream_lag
base: unstable
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1f3e64f
Fix incorrect lag firled in XINFO when tombstone is after the last_id…
sundb 2576c62
streamEstimateDistanceFromFirstEverEntry() returns SCG_INVALID_ENTRIE…
sundb d511793
Incrementing entries_read when there are no tombstones between betwee…
sundb 4b3db1a
Fix lag and entries read consistency in xinfo command
artikell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1127,7 +1127,7 @@ start_server { | |
set group [lindex [dict get $reply groups] 0] | ||
assert_equal [dict get $reply max-deleted-entry-id] "0-0" | ||
assert_equal [dict get $reply entries-added] 0 | ||
assert_equal [dict get $group entries-read] {} | ||
assert_equal [dict get $group entries-read] 0 | ||
assert_equal [dict get $group lag] 0 | ||
|
||
r XADD x 1-0 data a | ||
|
@@ -1137,7 +1137,7 @@ start_server { | |
set group [lindex [dict get $reply groups] 0] | ||
assert_equal [dict get $reply max-deleted-entry-id] "1-0" | ||
assert_equal [dict get $reply entries-added] 1 | ||
assert_equal [dict get $group entries-read] {} | ||
assert_equal [dict get $group entries-read] 1 | ||
assert_equal [dict get $group lag] 0 | ||
} | ||
|
||
|
@@ -1152,7 +1152,7 @@ start_server { | |
|
||
set reply [r XINFO STREAM x FULL] | ||
set group [lindex [dict get $reply groups] 0] | ||
assert_equal [dict get $group entries-read] {} | ||
assert_equal [dict get $group entries-read] 0 | ||
assert_equal [dict get $group lag] 5 | ||
|
||
r XREADGROUP GROUP g1 c11 COUNT 1 STREAMS x > | ||
|
@@ -1226,7 +1226,7 @@ start_server { | |
assert_equal [dict get $group entries-read] 5 | ||
assert_equal [dict get $group lag] 1 | ||
set group [lindex [dict get $reply groups] 1] | ||
assert_equal [dict get $group entries-read] {} | ||
assert_equal [dict get $group entries-read] 3 | ||
assert_equal [dict get $group lag] 3 | ||
|
||
r XTRIM x MINID = 5-0 | ||
|
@@ -1235,10 +1235,69 @@ start_server { | |
assert_equal [dict get $group entries-read] 5 | ||
assert_equal [dict get $group lag] 1 | ||
set group [lindex [dict get $reply groups] 1] | ||
assert_equal [dict get $group entries-read] {} | ||
assert_equal [dict get $group entries-read] 4 | ||
assert_equal [dict get $group lag] 2 | ||
} | ||
|
||
test {Consumer group check lag and entries-read consistency} { | ||
r DEL x | ||
r XGROUP CREATE x processing $ MKSTREAM | ||
r XGROUP CREATE x processing1 $ MKSTREAM | ||
r XADD x 0-1 name Mercury | ||
r XADD x 0-2 name Venus | ||
r XADD x 0-3 name Earth | ||
r XADD x 0-4 name Jupiter | ||
|
||
r XREADGROUP GROUP processing alice COUNT 2 STREAMS x > | ||
r XDEL x 0-3 | ||
|
||
set reply [r XINFO STREAM x FULL] | ||
set group [lindex [dict get $reply groups] 0] | ||
assert_equal [dict get $group entries-read] {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why isn't it 2? |
||
assert_equal [dict get $group lag] {} | ||
|
||
r DEL x | ||
r XGROUP CREATE x processing $ MKSTREAM | ||
r XGROUP CREATE x processing1 $ MKSTREAM | ||
r XADD x 0-1 name Mercury | ||
r XADD x 0-2 name Venus | ||
r XADD x 0-3 name Earth | ||
r XADD x 0-4 name Jupiter | ||
|
||
r XDEL x 0-3 | ||
r XREADGROUP GROUP processing alice COUNT 2 STREAMS x > | ||
|
||
set reply [r XINFO STREAM x FULL] | ||
set group [lindex [dict get $reply groups] 0] | ||
assert_equal [dict get $group entries-read] {} | ||
assert_equal [dict get $group lag] {} | ||
} | ||
|
||
test {Consumer Group Lag with XDELs and tombstone after the last_id of consume group} { | ||
r DEL x | ||
r XGROUP CREATE x g1 $ MKSTREAM | ||
r XADD x 1-0 data a | ||
r XREADGROUP GROUP g1 alice STREAMS x > ;# Read one entry | ||
r XADD x 2-0 data c | ||
r XADD x 3-0 data d | ||
r XDEL x 1-0 | ||
r XDEL x 2-0 | ||
# Now the latest tombstone(2-0) is before the first entry(3-0), but there is still | ||
# a tombstone(2-0) after the last_id of the consume group. | ||
set reply [r XINFO STREAM x FULL] | ||
set group [lindex [dict get $reply groups] 0] | ||
assert_equal [dict get $group entries-read] {} | ||
assert_equal [dict get $group lag] {} | ||
|
||
# Now there is a tombstone(2-0) after the last_id of the consume group, so after consuming | ||
# entry(3-0), the group's counter will be invalid. | ||
r XREADGROUP GROUP g1 alice STREAMS x > | ||
set reply [r XINFO STREAM x FULL] | ||
set group [lindex [dict get $reply groups] 0] | ||
assert_equal [dict get $group entries-read] 3 | ||
assert_equal [dict get $group lag] 0 | ||
} | ||
|
||
test {Loading from legacy (Redis <= v6.2.x, rdb_ver < 10) persistence} { | ||
# The payload was DUMPed from a v5 instance after: | ||
# XADD x 1-0 data a | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it 1? i don't see any
XREADGROUP
command.