Skip to content

Commit a7d8420

Browse files
committed
kvserver: use LogEngine to store fatal file
This decision is somewhat arbitrary, but seems logical to use the LogEngine as the source of truth for now. For the fatal file, it could also be either place, and both being checked on startup. A reason to switch to the other engin might be that we decide to use the FS directly only in one of the two engines, and then that would be StateEngine because we already use it for the sideloaded log entry files. But we aren't making this decision at this point. Epic: none Release note: none
1 parent 5ce05b7 commit a7d8420

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

pkg/kv/kvserver/replica_consistency.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ func (r *Replica) computeChecksumPostApply(
679679

680680
// Caller is holding raftMu, so an engine snapshot is automatically
681681
// Raft-consistent (i.e. not in the middle of an AddSSTable).
682-
snap := r.store.TODOEngine().NewSnapshot(rditer.MakeReplicatedKeySpans(&desc)...)
682+
snap := r.store.StateEngine().NewSnapshot(rditer.MakeReplicatedKeySpans(&desc)...)
683683
if util.RaceEnabled {
684684
ss := rditer.MakeReplicatedKeySpanSet(&desc)
685685
defer ss.Release()
@@ -767,8 +767,12 @@ func (r *Replica) computeChecksumPostApply(
767767
// early, the reply won't make it back to the leaseholder, so it will not be
768768
// certain of completing the check. Since we're already in a goroutine
769769
// that's about to end, just sleep for a few seconds and then terminate.
770-
auxDir := r.store.TODOEngine().GetAuxiliaryDir()
771-
_ = r.store.TODOEngine().Env().MkdirAll(auxDir, os.ModePerm)
770+
//
771+
// TODO(sep-raft-log): the decision to store the fatal file in LogEngine is
772+
// somewhat arbitrary, make sure it's fine.
773+
eng := r.store.LogEngine()
774+
auxDir := eng.GetAuxiliaryDir()
775+
_ = eng.Env().MkdirAll(auxDir, os.ModePerm)
772776
path := base.PreventedStartupFile(auxDir)
773777

774778
const attentionFmt = `ATTENTION:
@@ -811,7 +815,7 @@ creation. These directories should be deleted, or inspected with caution.
811815
`
812816
attentionArgs := []any{r, desc.Replicas(), redact.Safe(auxDir), redact.Safe(path)}
813817
preventStartupMsg := fmt.Sprintf(attentionFmt, attentionArgs...)
814-
if err := fs.WriteFile(r.store.TODOEngine().Env(), path, []byte(preventStartupMsg), fs.UnspecifiedWriteCategory); err != nil {
818+
if err := fs.WriteFile(eng.Env(), path, []byte(preventStartupMsg), fs.UnspecifiedWriteCategory); err != nil {
815819
log.KvExec.Warningf(ctx, "%v", err)
816820
}
817821

pkg/kv/kvserver/replica_corruption.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ func (r *Replica) setCorruptRaftMuLocked(
4545
cErr.Processed = true
4646
r.shMu.destroyStatus.Set(cErr, destroyReasonRemoved)
4747

48-
auxDir := r.store.TODOEngine().GetAuxiliaryDir()
49-
_ = r.store.TODOEngine().Env().MkdirAll(auxDir, os.ModePerm)
48+
// TODO(sep-raft-log): same as in replica_consistency.go, make sure storing
49+
// files into the LogEngine is canonical.
50+
eng := r.store.LogEngine()
51+
auxDir := eng.GetAuxiliaryDir()
52+
_ = eng.Env().MkdirAll(auxDir, os.ModePerm)
5053
path := base.PreventedStartupFile(auxDir)
5154

5255
preventStartupMsg := fmt.Sprintf(`ATTENTION:
@@ -59,7 +62,7 @@ A file preventing this node from restarting was placed at:
5962
%s
6063
`, r, path)
6164

62-
if err := fs.WriteFile(r.store.TODOEngine().Env(), path, []byte(preventStartupMsg), fs.UnspecifiedWriteCategory); err != nil {
65+
if err := fs.WriteFile(eng.Env(), path, []byte(preventStartupMsg), fs.UnspecifiedWriteCategory); err != nil {
6366
log.KvExec.Warningf(ctx, "%v", err)
6467
}
6568

0 commit comments

Comments
 (0)