Skip to content

Commit bee9ca3

Browse files
committed
#XD-780 reproduced
1 parent 6b1a20a commit bee9ca3

File tree

1 file changed

+58
-4
lines changed

1 file changed

+58
-4
lines changed

environment/src/test/kotlin/jetbrains/exodus/gc/GarbageCollectorTest.kt

+58-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ package jetbrains.exodus.gc
1717

1818
import jetbrains.exodus.bindings.IntegerBinding
1919
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.*
2421
import org.junit.Assert
2522
import org.junit.Test
2623

@@ -301,6 +298,63 @@ open class GarbageCollectorTest : EnvironmentTestsBase() {
301298
Assert.assertEquals(1L, env.log.numberOfFiles)
302299
}
303300

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+
}
304358

305359
protected fun openStoreAutoCommit(name: String): StoreImpl {
306360
return openStoreAutoCommit(name, getStoreConfig(false)) as StoreImpl

0 commit comments

Comments
 (0)