JetStream: clear erased bit when reading sequence number

Also changed the link to travis-ci.com instead of .org

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2020-10-29 13:09:13 -06:00
parent 5adce5c01c
commit 04450f2d99
3 changed files with 12 additions and 10 deletions

View File

@@ -27,8 +27,8 @@ If you are interested in contributing to NATS, read about our...
[License-Image]: https://img.shields.io/badge/License-Apache2-blue.svg
[Fossa-Url]: https://app.fossa.io/projects/git%2Bgithub.com%2Fnats-io%2Fgnatsd?ref=badge_shield
[Fossa-Image]: https://app.fossa.io/api/projects/git%2Bgithub.com%2Fnats-io%2Fgnatsd.svg?type=shield
[Build-Status-Url]: https://travis-ci.org/nats-io/nats-server
[Build-Status-Image]: https://travis-ci.org/nats-io/nats-server.svg?branch=master
[Build-Status-Url]: https://travis-ci.com/github/nats-io/nats-server
[Build-Status-Image]: https://travis-ci.com/nats-io/nats-server.svg?branch=master
[Release-Url]: https://github.com/nats-io/nats-server/releases/tag/v2.1.8
[Release-image]: https://img.shields.io/badge/release-v2.1.8-1eb0fc.svg
[Coverage-Url]: https://coveralls.io/r/nats-io/nats-server?branch=master

View File

@@ -434,7 +434,8 @@ func (fs *fileStore) recoverMsgBlock(fi os.FileInfo, index uint64) *msgBlock {
// This is an old erased message, or a new one that we can track.
if seq == 0 || seq&ebit != 0 {
addToDmap(seq &^ ebit)
seq = seq &^ ebit
addToDmap(seq)
offset += int64(rl)
continue
}
@@ -2086,7 +2087,7 @@ func (mb *msgBlock) readIndexInfo() error {
return 0
}
bi += n
return seq
return seq &^ ebit
}
readCount := readSeq
readTimeStamp := func() int64 {

View File

@@ -293,13 +293,14 @@ func TestFileStoreSkipMsg(t *testing.T) {
fs.SkipMsg()
fs.SkipMsg()
fs.StoreMsg("zzz", nil, []byte("Hello World!"))
fs.SkipMsg()
state = fs.State()
if state.Msgs != 2 {
t.Fatalf("Expected %d msgs, got %d", 2, state.Msgs)
}
if state.FirstSeq != uint64(numSkips+1) || state.LastSeq != uint64(numSkips+4) {
t.Fatalf("Expected first to be %d and last to be %d. got first %d and last %d", numSkips+1, numSkips+4, state.FirstSeq, state.LastSeq)
if state.FirstSeq != uint64(numSkips+1) || state.LastSeq != uint64(numSkips+5) {
t.Fatalf("Expected first to be %d and last to be %d. got first %d and last %d", numSkips+1, numSkips+5, state.FirstSeq, state.LastSeq)
}
// Make sure we recover same state.
@@ -315,8 +316,8 @@ func TestFileStoreSkipMsg(t *testing.T) {
if state.Msgs != 2 {
t.Fatalf("Expected %d msgs, got %d", 2, state.Msgs)
}
if state.FirstSeq != uint64(numSkips+1) || state.LastSeq != uint64(numSkips+4) {
t.Fatalf("Expected first to be %d and last to be %d. got first %d and last %d", numSkips+1, numSkips+4, state.FirstSeq, state.LastSeq)
if state.FirstSeq != uint64(numSkips+1) || state.LastSeq != uint64(numSkips+5) {
t.Fatalf("Expected first to be %d and last to be %d. got first %d and last %d", numSkips+1, numSkips+5, state.FirstSeq, state.LastSeq)
}
subj, _, msg, _, err := fs.LoadMsg(11)
@@ -332,8 +333,8 @@ func TestFileStoreSkipMsg(t *testing.T) {
if err != nil {
t.Fatalf("Unexpected error looking up seq 11: %v", err)
}
if nseq != 16 {
t.Fatalf("Expected seq of %d but got %d", 16, nseq)
if nseq != 17 {
t.Fatalf("Expected seq of %d but got %d", 17, nseq)
}
// Make sure we recover same state.