ENT-2691 Soft locking got regressed in Enterprise (#1539)

* Fix soft locking regression

* Fix caffeine version in core

* Fix default cache bound
This commit is contained in:
Rick Parker 2018-11-06 11:40:28 +00:00 committed by GitHub
parent 9a778b0097
commit 59504b4439
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 17 deletions

View File

@ -87,7 +87,7 @@ dependencies {
testCompile "com.google.guava:guava:$guava_version"
// For caches rather than guava
compile "com.github.ben-manes.caffeine:caffeine:$caffeine_version"
compile "com.github.corda.caffeine:caffeine:cfca283c984d93d520bfcde234920ea0840402ee"
// Smoke tests do NOT have any Node code on the classpath!
smokeTestCompile project(':smoke-test-utils')

View File

@ -10,12 +10,10 @@ import net.corda.core.internal.*
import net.corda.core.messaging.DataFeed
import net.corda.core.node.ServicesForResolution
import net.corda.core.node.StatesToRecord
import net.corda.core.node.services.*
import net.corda.core.node.services.KeyManagementService
import net.corda.core.node.services.StatesNotAvailableException
import net.corda.core.node.services.Vault
import net.corda.core.node.services.Vault.ConstraintInfo.Companion.constraintInfo
import net.corda.core.node.services.vault.*
import net.corda.core.node.services.VaultQueryException
import net.corda.core.node.services.vault.*
import net.corda.core.schemas.PersistentStateRef
@ -121,14 +119,14 @@ class NodeVaultService(
val session = currentDBSession()
val now = clock.instant()
producedStateRefsMap.forEach { stateAndRef ->
val uuid = if (stateAndRef.value.state.data is FungibleAsset<*>) {
val stateOnly = stateAndRef.value.state.data
val uuid = if (stateOnly is FungibleState<*>) {
FlowStateMachineImpl.currentStateMachine()?.id?.uuid?.toString()
} else null
if (uuid != null) {
FlowStateMachineImpl.currentStateMachine()?.hasSoftLockedStates = true
log.trace { "Reserving soft lock for flow id $uuid and state ${stateAndRef.key}" }
}
val stateOnly = stateAndRef.value.state.data
// TODO: Optimise this.
//
// For EVERY state to be committed to the vault, this checks whether it is spendable by the recording
@ -333,17 +331,6 @@ class NodeVaultService(
// flowId was required by SoftLockManager to perform auto-registration of soft locks for new states
val uuid = (Strand.currentStrand() as? FlowStateMachineImpl<*>)?.id?.uuid
val vaultUpdate = if (uuid != null) netUpdate.copy(flowId = uuid) else netUpdate
if (uuid != null) {
val fungible = netUpdate.produced.filter { stateAndRef ->
val state = stateAndRef.state.data
state is FungibleAsset<*> || state is FungibleState<*>
}
if (fungible.isNotEmpty()) {
val stateRefs = fungible.map { it.ref }.toNonEmptySet()
log.trace { "Reserving soft locks for flow id $uuid and states $stateRefs" }
softLockReserve(uuid, stateRefs)
}
}
persistentStateService.persist(vaultUpdate.produced)
updatesPublisher.onNext(vaultUpdate)
}

View File

@ -28,7 +28,7 @@ class EnterpriseNamedCacheFactory private constructor(private val tracingConfig:
// This results in a minium of 1024 entries as per OS, but then grows linearly with attachment cache size.
private fun defaultAttachmentPresenceCacheBound(nodeConfiguration: NodeConfiguration): Long = defaultAttachmentCacheBound(nodeConfiguration) / 10.KB
override val defaultCacheSize = if (nodeConfiguration == null) super.defaultCacheSize else defaultAttachmentCacheBound(nodeConfiguration)
override val defaultCacheSize = if (nodeConfiguration == null) super.defaultCacheSize else defaultBound(nodeConfiguration)
override fun <K, V> configuredForNamed(caffeine: Caffeine<K, V>, name: String): Caffeine<K, V> {
return with(nodeConfiguration!!) {