@@ -232,19 +232,9 @@ func (s *store) checkPrevCompactionCompleted() bool {
232
232
tx := s .b .ReadTx ()
233
233
tx .Lock ()
234
234
defer tx .Unlock ()
235
- _ , scheduledCompactBytes := tx .UnsafeRange (buckets .Meta , scheduledCompactKeyName , nil , 0 )
236
- scheduledCompact := int64 (0 )
237
- if len (scheduledCompactBytes ) != 0 {
238
- scheduledCompact = bytesToRev (scheduledCompactBytes [0 ]).main
239
- }
240
-
241
- _ , finishedCompactBytes := tx .UnsafeRange (buckets .Meta , finishedCompactKeyName , nil , 0 )
242
- finishedCompact := int64 (0 )
243
- if len (finishedCompactBytes ) != 0 {
244
- finishedCompact = bytesToRev (finishedCompactBytes [0 ]).main
245
-
246
- }
247
- return scheduledCompact == finishedCompact
235
+ scheduledCompact , scheduledCompactFound := UnsafeReadScheduledCompact (tx )
236
+ finishedCompact , finishedCompactFound := UnsafeReadFinishedCompact (tx )
237
+ return scheduledCompact == finishedCompact && scheduledCompactFound == finishedCompactFound
248
238
}
249
239
250
240
func (s * store ) compact (trace * traceutil.Trace , rev , prevCompactRev int64 , prevCompactionCompleted bool ) (<- chan struct {}, error ) {
@@ -343,10 +333,10 @@ func (s *store) restore() error {
343
333
tx := s .b .ReadTx ()
344
334
tx .Lock ()
345
335
346
- _ , finishedCompactBytes := tx . UnsafeRange ( buckets . Meta , finishedCompactKeyName , nil , 0 )
347
- if len ( finishedCompactBytes ) != 0 {
336
+ finishedCompact , found := UnsafeReadFinishedCompact ( tx )
337
+ if found {
348
338
s .revMu .Lock ()
349
- s .compactMainRev = bytesToRev ( finishedCompactBytes [ 0 ]). main
339
+ s .compactMainRev = finishedCompact
350
340
351
341
s .lg .Info (
352
342
"restored last compact revision" ,
@@ -356,11 +346,7 @@ func (s *store) restore() error {
356
346
)
357
347
s .revMu .Unlock ()
358
348
}
359
- _ , scheduledCompactBytes := tx .UnsafeRange (buckets .Meta , scheduledCompactKeyName , nil , 0 )
360
- scheduledCompact := int64 (0 )
361
- if len (scheduledCompactBytes ) != 0 {
362
- scheduledCompact = bytesToRev (scheduledCompactBytes [0 ]).main
363
- }
349
+ scheduledCompact , _ := UnsafeReadScheduledCompact (tx )
364
350
365
351
// index keys concurrently as they're loaded in from tx
366
352
keysGauge .Set (0 )
0 commit comments