Skip to content

Commit 0e2b057

Browse files
committed
kvserver: clarify HLCUpperBound being in LogEngine
Epic: none Release note: none
1 parent 2b330b3 commit 0e2b057

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

pkg/kv/kvserver/store.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,7 +2932,7 @@ func (s *Store) WriteLastUpTimestamp(ctx context.Context, time hlc.Timestamp) er
29322932
ctx = s.AnnotateCtx(ctx)
29332933
return storage.MVCCPutProto(
29342934
ctx,
2935-
s.TODOEngine(), // TODO(sep-raft-log): probably state engine
2935+
s.LogEngine(),
29362936
keys.StoreLastUpKey(),
29372937
hlc.Timestamp{},
29382938
&time,
@@ -2947,7 +2947,7 @@ func (s *Store) WriteLastUpTimestamp(ctx context.Context, time hlc.Timestamp) er
29472947
// timestamp is returned instead.
29482948
func (s *Store) ReadLastUpTimestamp(ctx context.Context) (hlc.Timestamp, error) {
29492949
var timestamp hlc.Timestamp
2950-
ok, err := storage.MVCCGetProto(ctx, s.TODOEngine(), keys.StoreLastUpKey(), hlc.Timestamp{},
2950+
ok, err := storage.MVCCGetProto(ctx, s.LogEngine(), keys.StoreLastUpKey(), hlc.Timestamp{},
29512951
&timestamp, storage.MVCCGetOptions{})
29522952
if err != nil {
29532953
return hlc.Timestamp{}, err
@@ -2961,8 +2961,8 @@ func (s *Store) ReadLastUpTimestamp(ctx context.Context) (hlc.Timestamp, error)
29612961
func (s *Store) WriteHLCUpperBound(ctx context.Context, time int64) error {
29622962
ctx = s.AnnotateCtx(ctx)
29632963
ts := hlc.Timestamp{WallTime: time}
2964-
batch := s.TODOEngine().NewBatch() // TODO(sep-raft-log): state engine might be useful here due to need to sync
2965-
// Write has to sync to disk to ensure HLC monotonicity across restarts
2964+
// Write has to sync to disk to ensure HLC monotonicity across restarts.
2965+
batch := s.LogEngine().NewBatch()
29662966
defer batch.Close()
29672967
if err := storage.MVCCPutProto(
29682968
ctx,
@@ -2974,11 +2974,7 @@ func (s *Store) WriteHLCUpperBound(ctx context.Context, time int64) error {
29742974
); err != nil {
29752975
return err
29762976
}
2977-
2978-
if err := batch.Commit(true /* sync */); err != nil {
2979-
return err
2980-
}
2981-
return nil
2977+
return batch.Commit(true /* sync */)
29822978
}
29832979

29842980
// ReadHLCUpperBound returns the upper bound to the wall time of the HLC

pkg/server/clock_monotonicity.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ func (s *topLevelServer) checkHLCUpperBoundExistsAndEnsureMonotonicity(
7575
return false, nil
7676
}
7777

78+
// TODO(sep-raft-log): make sure we're reading only from log engines. There
79+
// seems to be no harm in reading from state engines too (and seeing zeroes),
80+
// but the HLC key is in the log engines.
7881
hlcUpperBound, err := kvserver.ReadMaxHLCUpperBound(ctx, s.engines)
7982
if err != nil {
8083
return false, errors.Wrap(err, "reading max HLC upper bound")

0 commit comments

Comments
 (0)