mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
Merge pull request #7275 from corda/parkri/ENT-8817-compute-deadlocks
ENT-8817 OS port of compute deadlock changes
This commit is contained in:
commit
23b872db17
@ -73,7 +73,7 @@ class InfrequentlyMutatedCache<K : Any, V : Any>(name: String, cacheFactory: Nam
|
||||
backingCache.invalidateAll()
|
||||
}
|
||||
|
||||
private fun invalidate(key: K, value: Wrapper.Invalidated<V>): Wrapper.Invalidated<V> {
|
||||
private fun invalidate(key: K, value: Wrapper.Invalidated<V>): Wrapper.Invalidated<V>? {
|
||||
val tx = contextTransactionOrNull
|
||||
value.invalidators.incrementAndGet()
|
||||
currentlyInvalid[key] = value
|
||||
@ -81,7 +81,10 @@ class InfrequentlyMutatedCache<K : Any, V : Any>(name: String, cacheFactory: Nam
|
||||
// When we close, we can't start using caching again until all simultaneously open transactions are closed.
|
||||
tx.onClose { tx.database.onAllOpenTransactionsClosed { decrementInvalidators(key, value) } }
|
||||
} else {
|
||||
decrementInvalidators(key, value)
|
||||
if (value.invalidators.decrementAndGet() == 0) {
|
||||
currentlyInvalid.remove(key)
|
||||
return null
|
||||
}
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
@ -25,6 +25,11 @@ class InfrequentlyMutatedCacheTest {
|
||||
database.close()
|
||||
}
|
||||
|
||||
@Test(timeout = 300_000)
|
||||
fun `invalidate outside transaction should not hang`() {
|
||||
cache.invalidate("Fred")
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `get from empty cache returns result of loader`() {
|
||||
database.transaction {
|
||||
|
Loading…
Reference in New Issue
Block a user