Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Unified Diff: logdog/common/storage/archive/storage.go

Issue 2422393002: Fix sparse index handling, add index params. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: logdog/common/storage/archive/storage.go
diff --git a/logdog/common/storage/archive/storage.go b/logdog/common/storage/archive/storage.go
index be8c18dffd21f9b5e255849082b4ba756c56239b..6800adfb8bb50d2ce01a0ecff9ec59268e441fc0 100644
--- a/logdog/common/storage/archive/storage.go
+++ b/logdog/common/storage/archive/storage.go
@@ -115,8 +115,9 @@ func (s *storageImpl) Get(req storage.GetRequest, cb storage.GetCallback) error
// Identify the byte offsets that we want to fetch from the entries stream.
st := s.buildGetStrategy(&req, idx)
- if st.lastIndex == -1 || req.Index > st.lastIndex {
- // No records to read.
+ if st.lastIndex >= 0 && req.Index > st.lastIndex {
+ // We know the last index, and the user requested logs past it, so there are
+ // no records to read.
return nil
}
@@ -312,14 +313,19 @@ func (gs *getStrategy) setEndOffset(v uint64) {
}
func (s *storageImpl) buildGetStrategy(req *storage.GetRequest, idx *logpb.LogIndex) *getStrategy {
- st := getStrategy{}
+ st := getStrategy{
+ lastIndex: -1,
+ }
if len(idx.Entries) == 0 {
- st.lastIndex = -1
return &st
}
- st.lastIndex = types.MessageIndex(idx.Entries[len(idx.Entries)-1].StreamIndex)
dnj 2016/10/17 22:12:12 The actual bug: if there is a sparse index whose l
+ // If we have a log entry count, mark the last log index.
+ if idx.LogEntryCount > 0 {
+ st.lastIndex = types.MessageIndex(idx.Entries[len(idx.Entries)-1].StreamIndex)
+ }
+
startIdx := indexEntryFor(idx.Entries, req.Index)
if startIdx < 0 {
startIdx = 0

Powered by Google App Engine
This is Rietveld 408576698