@@ -17,10 +17,7 @@ package jetbrains.exodus.gc
17
17
18
18
import jetbrains.exodus.bindings.IntegerBinding
19
19
import jetbrains.exodus.bindings.StringBinding
20
- import jetbrains.exodus.env.EnvironmentTestsBase
21
- import jetbrains.exodus.env.Store
22
- import jetbrains.exodus.env.StoreConfig
23
- import jetbrains.exodus.env.StoreImpl
20
+ import jetbrains.exodus.env.*
24
21
import org.junit.Assert
25
22
import org.junit.Test
26
23
@@ -301,6 +298,63 @@ open class GarbageCollectorTest : EnvironmentTestsBase() {
301
298
Assert .assertEquals(1L , env.log.numberOfFiles)
302
299
}
303
300
301
+ @Test
302
+ fun `stackoverflow-com-questions-56662998` () {
303
+ env.environmentConfig.run {
304
+ gcStartIn = 0
305
+ gcFileMinAge = 1
306
+ gcFilesDeletionDelay = 0
307
+ gcMinUtilization = 90
308
+ }
309
+ setLogFileSize(1 )
310
+ val store = openStoreAutoCommit(" store" )
311
+ env.executeInExclusiveTransaction { txn ->
312
+ for (i in 1 .. 1000 ) {
313
+ store.putRight(txn, IntegerBinding .intToEntry(i), IntegerBinding .intToEntry(i))
314
+ }
315
+ }
316
+ Assert .assertTrue(env.log.numberOfFiles > 1L )
317
+ env.executeInExclusiveTransaction { txn ->
318
+ store.openCursor(txn).use { cursor ->
319
+ cursor.forEach { deleteCurrent() }
320
+ }
321
+ }
322
+ env.gc()
323
+ env.gc.cleaner.getJobProcessor().run {
324
+ repeat(4 ) {
325
+ waitForJobs(100 )
326
+ }
327
+ }
328
+ Assert .assertEquals(1L , env.log.numberOfFiles)
329
+ }
330
+
331
+ @Test
332
+ fun `stackoverflow-com-questions-56662998+` () {
333
+ env.environmentConfig.run {
334
+ gcStartIn = 0
335
+ gcFileMinAge = 1
336
+ gcFilesDeletionDelay = 0
337
+ gcMinUtilization = 90
338
+ }
339
+ setLogFileSize(1 )
340
+ val store = openStoreAutoCommit(" store" )
341
+ env.executeInExclusiveTransaction { txn ->
342
+ for (i in 1 .. 1000 ) {
343
+ store.putRight(txn, IntegerBinding .intToEntry(i), IntegerBinding .intToEntry(i))
344
+ }
345
+ }
346
+ Assert .assertTrue(env.log.numberOfFiles > 1L )
347
+ env.executeInExclusiveTransaction { txn ->
348
+ env.truncateStore(" store" , txn)
349
+ }
350
+ env.gc()
351
+ env.gc.cleaner.getJobProcessor().run {
352
+ repeat(4 ) {
353
+ waitForJobs(100 )
354
+ }
355
+ }
356
+ Assert .assertEquals(1L , env.log.numberOfFiles)
357
+ }
304
358
305
359
protected fun openStoreAutoCommit (name : String ): StoreImpl {
306
360
return openStoreAutoCommit(name, getStoreConfig(false )) as StoreImpl
0 commit comments