@@ -309,12 +309,14 @@ data QueryRunner = QueryRunner {
309
309
instance ChangeLogger () where
310
310
logChangelog () _ = return ()
311
311
getChangelogProgress () = return minBound
312
+ trimChangelog () _ = return ()
312
313
313
314
-- use logdevice stream
314
315
instance ChangeLogger (S. LDClient , S. C_LogID ) where
315
316
logChangelog (ldClient, logId) bs =
316
317
void $ S. append ldClient logId (lazyByteStringToBytes bs) Nothing
317
318
getChangelogProgress (ldClient, logId) = S. getTailLSN ldClient logId
319
+ trimChangelog (ldClient, logId) lsn = S. trim ldClient logId lsn
318
320
319
321
---- store processing node states (snapshot)
320
322
-- do nothing
@@ -325,6 +327,8 @@ instance Snapshotter () where
325
327
instance Snapshotter RocksDB. DB where
326
328
snapshot db = RocksDB. put db def
327
329
330
+ -- | Do snapshot for a task, then trim old changelogs for this task.
331
+ -- May throw exceptions.
328
332
doSnapshot :: (ChangeLogger h1 , Snapshotter h2 ) => h1 -> h2 -> Task -> IO ()
329
333
doSnapshot h1 h2 Task {.. } = do
330
334
changelogTail <- getChangelogProgress h1
@@ -350,6 +354,8 @@ doSnapshot h1 h2 Task{..} = do
350
354
valueSer = BL. toStrict $ Aeson. encode value
351
355
snapshot h2 keySer valueSer
352
356
Log. debug $ " Query " <> Log. build taskName <> " : I have successfully done a snapshot!"
357
+ trimChangelog h1 changelogTail
358
+ Log. debug $ " Query " <> Log. build taskName <> " : I have successfully trimmed the old changelog!"
353
359
354
360
--------------------------------------------------------------------------------
355
361
0 commit comments