Improve emitted change feed sequence after a split - #4643
Merged
Conversation
Contributor
Author
|
Using the script from #4640 to test it as well: #!/bin/bash
CDB_AUTH='adm:pass'
CDB_HOST='127.0.0.1'
CDB_PORT=15984
cdb () {
curl -gs -H 'Content-Type: application/json' "$(cdb-host)$1" "${@:2}"
}
cdb-host () {
echo "http://${CDB_AUTH}@${CDB_HOST}:${CDB_PORT}"
}
stop-jobs () {
cdb '/_reshard/jobs' | jq -r '.jobs[] | .id' | while read -r id ; do
cdb "/_reshard/jobs/$id" -X DELETE
done
}
split-shards () {
local db="$1"
cdb "/$db/_shards" | jq -r '.shards | keys[]' | while read -r range ; do
cdb '/_reshard/jobs' -X POST \
-d '{ "type": "split", "db": "'$db'", "range": "'$range'" }'
done
}
wait-for-q () {
local db="$1"
local q="$2"
while [[ $(cdb "/$db" | jq -r '.cluster.q') != $q ]] ; do
sleep 1
done
}
db='test-db'
cdb "/$db" -X DELETE
cdb "/$db?q=2" -X PUT
for n in {1..10} ; do
cdb "/$db/doc-$n" -X PUT -d '{ "n": '$n' }'
done
last_seq_q2="$(cdb "/$db/_changes" | jq -r '.last_seq')"
stop-jobs
split-shards "$db"
wait-for-q "$db" 4
last_seq_q4="$(cdb "/$db/_changes" | jq -r '.last_seq')"
cdb "/$db/_changes?since=$last_seq_q2" | jq
stop-jobs
split-shards "$db"
wait-for-q "$db" 8
last_seq_q8="$(cdb "/$db/_changes" | jq -r '.last_seq')"
cdb "/$db/_changes?since=$last_seq_q4" | jq
cdb "/$db/_changes?since=$last_seq_q2" | jq |
rnewson
requested changes
Jun 16, 2023
pgj
reviewed
Jun 16, 2023
nickva
force-pushed
the
prettify-split-sequences
branch
2 times, most recently
from
June 16, 2023 15:26
484cdac to
2e36155
Compare
When we get sequence before the split, we'll fill in the missing (now split)
ranges with a special `{split, OldNodeUUid}` marker. However, when sequences
are emitted in the changes API, that will make the N- prefix (SeqSum) bounce
around from higher to lower numbers, while users expect those to be mostly
incrementing. So take a conservative approach and assume it will be a full
rewind for that range, and use 0 instead. This is a purely cosmetic thing, when
we decode the sequence that prefix gets thrown away anyway.
To emphasize that the sequence prefix is mostly a visual aid, rename the seq/1
function to fake_packed_seq/1 with a comment about what it does and a note
about the special split case.
Fixes a part of issue: #4640
nickva
force-pushed
the
prettify-split-sequences
branch
from
June 16, 2023 15:31
2e36155 to
44081fc
Compare
rnewson
approved these changes
Jun 16, 2023
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When we get sequence before the split, we'll fill in the missing (now split) ranges with a special
{split, OldNodeUUid}marker. However, when sequences are emitted in the changes API, that will make the N- prefix (SeqSum) bounce around from higher to lower numbers, while users expect those to be mostly incrementing. So take a conservative approach and assume it will be a full rewind for that range, and use 0 instead. This is a purely cosmetic thing, when we decode the sequence that prefix gets thrown away anyway.To emphasize that the sequence prefix is mostly a visual aid, rename the
seq/1function tofake_packed_seq/1with a comment about what it does and a note about the special split case.Fixes a part of issue: #4640