Skip to content

Commit

Permalink
Remove useless adjustRevision
Browse files Browse the repository at this point in the history
  • Loading branch information
marco6 committed Oct 28, 2024
1 parent f7dd57b commit 5a05866
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
20 changes: 4 additions & 16 deletions pkg/kine/logstructured/logstructured.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ func (l *LogStructured) Get(ctx context.Context, key, rangeEnd string, limit, re
attribute.Int64("revision", revision),
)
defer func() {
l.adjustRevision(ctx, &revRet)
logrus.Debugf("GET %s, rev=%d => rev=%d, kv=%v, err=%v", key, revision, revRet, kvRet != nil, errRet)
span.SetAttributes(attribute.Int64("adjusted-revision", revRet))
span.SetAttributes(attribute.Int64("current-revision", revRet))
span.RecordError(errRet)
span.End()
}()
Expand Down Expand Up @@ -114,8 +113,7 @@ func (l *LogStructured) get(ctx context.Context, key, rangeEnd string, limit, re
span.AddEvent("key already compacted")
// ignore compacted when getting by revision
err = nil
}
if err != nil {
} else if err != nil {
return 0, nil, err
}
if revision != 0 {
Expand All @@ -127,16 +125,6 @@ func (l *LogStructured) get(ctx context.Context, key, rangeEnd string, limit, re
return rev, events[0], nil
}

func (l *LogStructured) adjustRevision(ctx context.Context, rev *int64) {
if *rev != 0 {
return
}

if newRev, err := l.log.CurrentRevision(ctx); err == nil {
*rev = newRev
}
}

func (l *LogStructured) Create(ctx context.Context, key string, value []byte, lease int64) (rev int64, created bool, err error) {
rev, created, err = l.log.Create(ctx, key, value, lease)
logrus.Debugf("CREATE %s, size=%d, lease=%d => rev=%d, err=%v", key, len(value), lease, rev, err)
Expand Down Expand Up @@ -184,7 +172,7 @@ func (l *LogStructured) Count(ctx context.Context, prefix, startKey string, revi
attribute.String("prefix", prefix),
attribute.String("startKey", startKey),
attribute.Int64("revision", revision),
attribute.Int64("adjusted-revision", revRet),
attribute.Int64("current-revision", revRet),
attribute.Int64("count", count),
)
span.RecordError(err)
Expand All @@ -202,7 +190,7 @@ func (l *LogStructured) Update(ctx context.Context, key string, value []byte, re
attribute.Int64("revision", revision),
attribute.Int64("lease", lease),
attribute.Int64("value-size", int64(len(value))),
attribute.Int64("adjusted-revision", revRet),
attribute.Int64("current-revision", revRet),
attribute.Bool("updated", updateRet),
)
span.End()
Expand Down
6 changes: 0 additions & 6 deletions pkg/kine/logstructured/sqllog/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,6 @@ func (s *SQLLog) List(ctx context.Context, prefix, startKey string, limit, revis
return 0, nil, err
}

if revision > 0 && revision < compactRevision {
return currentRevision, result, server.ErrCompacted
}

s.notifyWatcherPoll(currentRevision)

return currentRevision, result, err
}

Expand Down

0 comments on commit 5a05866

Please sign in to comment.