@@ -1344,17 +1344,6 @@ func (i *singleLevelIterator[I, PI, D, PD]) lastInternal() *base.InternalKV {
13441344// Note: compactionIterator.Next mirrors the implementation of Iterator.Next
13451345// due to performance. Keep the two in sync.
13461346func (i * singleLevelIterator [I , PI , D , PD ]) Next () * base.InternalKV {
1347- if invariants .Enabled && i .lastOpWasSeekPrefixGE .Get () {
1348- // If the previous operation was SeekPrefixGE that returned nil due to bloom
1349- // filter miss, the data block should not have been invalidated. This assertion
1350- // ensures the optimization to preserve loaded blocks is working correctly.
1351- if PD (& i .data ).IsDataInvalidated () {
1352- panic ("pebble: data block was invalidated after SeekPrefixGE returned nil due to bloom filter miss" )
1353- }
1354- }
1355- // Clear the tracking flag since this is no longer the next operation after SeekPrefixGE
1356- i .lastOpWasSeekPrefixGE .Set (false )
1357-
13581347 // The SeekPrefixGE might have returned a synthetic key with latest suffix
13591348 // contained in the sstable. If the caller is calling Next(), that means
13601349 // they want to move past the synthetic key and Next() is responsible for
@@ -1366,6 +1355,17 @@ func (i *singleLevelIterator[I, PI, D, PD]) Next() *base.InternalKV {
13661355 return i .seekPrefixGE (i .reader .Comparer .Split .Prefix (i .synthetic .seekKey ), i .synthetic .seekKey , base .SeekGEFlagsNone )
13671356 }
13681357
1358+ if invariants .Enabled && i .lastOpWasSeekPrefixGE .Get () {
1359+ // If the previous operation was SeekPrefixGE that returned nil due to bloom
1360+ // filter miss, the data block should not have been invalidated. This assertion
1361+ // ensures the optimization to preserve loaded blocks is working correctly.
1362+ if PD (& i .data ).IsDataInvalidated () {
1363+ panic ("pebble: data block was invalidated after SeekPrefixGE returned nil due to bloom filter miss" )
1364+ }
1365+ }
1366+ // Clear the tracking flag since this is no longer the next operation after SeekPrefixGE
1367+ i .lastOpWasSeekPrefixGE .Set (false )
1368+
13691369 if i .exhaustedBounds == + 1 {
13701370 panic ("Next called even though exhausted upper bound" )
13711371 }
0 commit comments