@@ -168,7 +168,7 @@ func (f *liteFile) Pragma(name, value string) (string, error) {
168168 if txid == 0 {
169169 // Outside transaction.
170170 f .db .mtx .Lock ()
171- txid = f .db .txids [f . db . opts . MinLevel ]
171+ txid = f .db .txids [0 ]
172172 f .db .mtx .Unlock ()
173173 }
174174 return txid .String (), nil
@@ -245,18 +245,18 @@ func (f *liteDB) pollReplica(ctx context.Context) (*pageIndex, ltx.TXID, error)
245245
246246 // Limit polling interval.
247247 if time .Since (f .lastPoll ) < f .opts .PollInterval {
248- return f .pages , f .txids [f . opts . MinLevel ], nil
248+ return f .pages , f .txids [0 ], nil
249249 }
250250
251- for level := range pollLevels ( f . opts . MinLevel ) {
251+ for level := range [] int { 0 , 1 , litestream . SnapshotLevel } {
252252 if err := f .updateLevel (ctx , level ); err != nil {
253253 f .opts .Logger .Error ("cannot poll replica" , "error" , err )
254254 return nil , 0 , err
255255 }
256256 }
257257
258258 f .lastPoll = time .Now ()
259- return f .pages , f .txids [f . opts . MinLevel ], nil
259+ return f .pages , f .txids [0 ], nil
260260}
261261
262262// +checklocks:f.mtx
@@ -313,26 +313,10 @@ func (f *liteDB) updateInfo(ctx context.Context, info *ltx.FileInfo) error {
313313 // Track the MaxTXID for each level.
314314 maxTXID := & f .txids [info .Level ]
315315 * maxTXID = max (* maxTXID , info .MaxTXID )
316+ f .txids [0 ] = max (f .txids [0 ], * maxTXID )
316317 return nil
317318}
318319
319- func pollLevels (minLevel int ) (r []int ) {
320- // Updating from lower to upper levels is non-racy,
321- // since LTX files are compacted into higher levels
322- // before the lower level LTX files are deleted.
323-
324- // Also, only level 0 compactions and snapshots delete files,
325- // so the intermediate levels never need to be updated.
326-
327- if minLevel <= 0 {
328- return append (r , 0 , 1 , litestream .SnapshotLevel )
329- }
330- if minLevel >= litestream .SnapshotLevel {
331- return append (r , litestream .SnapshotLevel )
332- }
333- return append (r , minLevel , litestream .SnapshotLevel )
334- }
335-
336320// Type aliases; these are a mouthful.
337321type pageIndex = wbt.Tree [uint32 , ltx.PageIndexElem ]
338322type levelTXIDs = [litestream .SnapshotLevel + 1 ]ltx.TXID
0 commit comments