Skip to content

Commit

Permalink
Merge pull request corda#2999 from corda/CORDA-1368/aslemmer-transact…
Browse files Browse the repository at this point in the history
…ion-wait-dbcommit

CORDA-1368: Add flow-id to MDC, small fix in DBTransactionStorage
  • Loading branch information
exFalso authored Apr 25, 2018
2 parents 8ce05e0 + 29dbe6a commit 88c1279
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class DBTransactionStorage(cacheSizeBytes: Long) : WritableTransactionStorage, S

override fun track(): DataFeed<List<SignedTransaction>, SignedTransaction> {
return txStorage.locked {
DataFeed(allPersisted().map { it.second.toSignedTx() }.toList(), updates.bufferUntilSubscribed().wrapWithDatabaseTransaction())
DataFeed(allPersisted().map { it.second.toSignedTx() }.toList(), updates.bufferUntilSubscribed())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import net.corda.nodeapi.internal.persistence.contextTransaction
import net.corda.nodeapi.internal.persistence.contextTransactionOrNull
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.slf4j.MDC
import java.util.concurrent.TimeUnit
import kotlin.reflect.KProperty1

Expand Down Expand Up @@ -164,11 +165,16 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
}
}

fun setLoggingContext() {
context.pushToLoggingContext()
MDC.put("flow-id", id.uuid.toString())
}

@Suspendable
override fun run() {
logic.stateMachine = this

context.pushToLoggingContext()
setLoggingContext()

initialiseFlow()

Expand Down Expand Up @@ -321,6 +327,7 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
require(continuation == FlowContinuation.ProcessEvents)
Fiber.unparkDeserialized(this, scheduler)
}
setLoggingContext()
return uncheckedCast(processEventsUntilFlowIsResumed(
isDbTransactionOpenOnEntry = false,
isDbTransactionOpenOnExit = true
Expand Down

0 comments on commit 88c1279

Please sign in to comment.