Commit Graph

2954 Commits

Author SHA1 Message Date
Dan Newton
8534aad3b1
ENT-5672 Know if paused flow is hospitalized (#6641)
Missing change from the original commit.
2020-08-15 10:08:37 +01:00
William Vigor
be6b76ff89
ENT-5684 Reconnect flow's progress tracker when unpausing (#6640)
Previously we were just throwing this away when pausing, meaning
updates would not be passed back to the user.

The progress tracker is now maintained in the `NonResidentFlow`
allowing it to be reused in the flow when it is retried.
2020-08-14 21:11:48 +01:00
William Vigor
32cb085a53
ENT-5672 Know if a paused flow is hospitalized (#6639)
* ENT-5672 Update database query to get paused flows which have previously been hospitalised

* NOTICK Remove unneeded check if a database exception was removed when switching a flow to RUNNABLE since we were to remove it anyway
2020-08-14 20:07:00 +01:00
Dan Newton
c4027e23bf
ENT-5649 Always load from db when flow retries (#6637)
Always attempt to load a checkpoint from the database when a flow
retries.

This is to prevent transient errors where the checkpoint is committed to
the database but throws an error back to the node. When the node tries
to retry in this scenario, `isAnyCheckpointPersisted` is false, meaning
that it will try to insert when it tries to save its initial checkpoint
again.

By loading from the existing checkpoint, even though it doesn't
really use it because it is `Unstarted`, the flag gets put into the
right state and will update rather than insert later on.
2020-08-14 17:42:19 +01:00
Matthew Nesbit
55133b02b9
Merge pull request #6626 from corda/bugfix/ENT-5654-run-migration-scripts-completes-with-unexpected-error
ENT-5654: Fixed migration error message, improved success message
2020-08-14 17:17:16 +01:00
Matthew Nesbit
2fb21373a4
Merge pull request #6632 from corda/nnagy-os-4.5-os-4.6-20200813
NOTICK - OS 4.5 to OS 4.6 merge 20200813
2020-08-14 16:16:40 +01:00
Yiftach Kaplan
da065a6215
CORDA-3981: Fix bad keys are ignored and warned for (#6636)
The issue with the test was that the environment variable are kept as a static member so it passed if it was the first one to run, but failed if another test runs the config beforehand.
2020-08-14 15:36:46 +01:00
Dan Newton
845ef8d3d1
CORDA-3989 Terminate sessions instantly (#6634)
Terminate sessions that need to be removed instantly in whatever transition is currently executing, rather than scheduling another event and doing so at a later time.

To do this, update the transition being created in `TopLevelTransition` to remove the sessions and append the `RemoveSessionBindings` action to it.

This achieves the same outcome as the original code but does so with 1 less transition. Doing this also removes the race condition that can occur where another external event is added to the flow's event queue before the terminate event could be added.
2020-08-14 11:13:42 +01:00
Dan Newton
1cbfb74022
CORDA-3986 Increase sleep in FlowSessionCloseTest (#6629)
* CORDA-3986 Increase sleep in `FlowSessionCloseTest`

A sleep duration needed to be increased to ensure that an end session
message has time to be processed by the other node.

Locks do not fully fix this because some internal processing needs to be
completed that can't be waited for using a lock. Therefore the sleep
time was increased generously.
2020-08-14 10:57:24 +01:00
Stefano Franz
205ce84033
[EG-3461] removed dependency from tools.jar (#6631)
* removed dependency from tools.jar

I removed the log line in /node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt because I felt it was not so important
and I modified the checkpoint agent detection simply using a static field (I tested both with and without the checkpoint agent running and detection works correctly)

* move method to node-api to address review comments

Co-authored-by: Walter Oggioni <walter.oggioni@r3.com>
2020-08-14 10:56:37 +01:00
Ross Nicoll
bf53e47f0d
ENT-5669 Improve robustness of FlowReloadAfterCheckpointTest (#6627)
Improve robustness of `FlowReloadAfterCheckpointTest` by adding a countdown latch to observe for when the reloads should have finished.
2020-08-13 15:04:52 +01:00
nikinagy
1a0e445a49 Merge branch 'release/os/4.5' into nnagy-os-4.5-os-4.6-20200813
# Conflicts:
#	node/src/main/kotlin/net/corda/node/services/vault/HibernateQueryCriteriaParser.kt
2020-08-13 14:25:58 +01:00
Edoardo Ierina
a7ea8df9a7
CORDA-3954: run database migration scripts during initial node registration (#6624)
* CORDA-3954: Added step to run database migration scripts during initial node registration with -s / --skip-schema-creation option (default to false) to prevent migration.

* CORDA-3954: Applied code convention to if statement

* CORDA-3954: Marked NodeCmdLineOptions' -s/--skip-schema-creation as deprecated and hidden in line with --initial-registration
2020-08-13 14:19:16 +01:00
Anurag Garg
294c2aa514
Merge pull request #6584 from filipesoliveira/filipeoliveira/corda-3931
CORDA-3931 - Fixed a bug which was preventing the custom JVM arguments from  being picked up when the command line "-f" flag was used
2020-08-13 14:13:09 +01:00
Ross Nicoll
4aea7b876a
ENT-5666 Disable test due to Gradle process death (#6617)
Disable `SignatureConstraintMigrationFromHashConstraintsTests.HashConstraint cannot be migrated to SignatureConstraint if a HashConstraint is specified for one state and another uses an AutomaticPlaceholderConstraint()` as it frequently appears in reports about Gradle process failures, to try isolating the actual cause.
2020-08-13 13:17:49 +01:00
Edoardo Ierina
07fe1b0960 ENT-5654: Fixed migration error message, improved success message 2020-08-13 11:32:56 +02:00
Nikolett Nagy
a6b2a3159d
CORDA-3879 - query with OR combinator returns too many results (#6456)
* fix suggestion and tests

* detekt suppress

* making sure the forced join works with IndirectStatePersistable and removing unnecessary joinPredicates from parse with sorting

* remove joinPredicates and add tests

* rename sorting

* revert deleting joinPredicates and modify the force join to use `OR` instead of `AND`

* add system property switch
2020-08-13 10:04:53 +01:00
Ross Nicoll
748480c33e
CORDA-3981 Disable unstable test (#6625) 2020-08-12 18:39:36 +01:00
Yiftach Kaplan
28b440d1f7
CORDA-3981: Change test to avoid timeout (#6612) 2020-08-12 10:31:58 +01:00
Ross Nicoll
9965af180e
CORDA-5985 Simplify network map test (#6618)
Remove parameterization from NetworkMapTest as it doesn't actually significantly improve coverage, and costs 6 and a half minutes on every build.
2020-08-12 09:01:58 +01:00
Ross Nicoll
12e7fa1d93
CORDA-3981 Disable unstable config helper test (#6610) 2020-08-10 20:35:15 +01:00
Ross Nicoll
29e87a586a
CORDA-3973 Fix memory leak due to DB not shutting down (#6605)
Fix memory leak due to DB not shutting down in FlowFrameworkPersistenceTests.flow restarted just after receiving payload.

Also reduces number of class-wide variables to reduce scope for references being accidentally held between runs.
2020-08-10 20:04:51 +01:00
Dan Newton
c191960cb8
CORDA-3948 Make KillFlowTest less flakey (#6606)
`KillFlowTest` is failing quite often. This is probably due to issues in ordering when taking and releasing locks. By using `CountDownLatch` in places instead of `Semaphore`s should reduce the likelihood of tests failing.
2020-08-10 16:59:28 +01:00
Yiftach Kaplan
8aafb1db4a
INFRA-545: Convert a few tests to unit tests; rename another test (#6562) 2020-08-10 15:25:28 +01:00
Dan Newton
66406ba0fb
ENT-5450 Resume flow when transition creation errors (#6604)
If an error occurs when creating a transition (a.k.a anything inside of
`TopLevelTransition`) then resume the flow with the error that occurred.

This is needed, because the current code is swallowing all errors thrown
at this point and causing the flow to hang.

This change will allow better debugging of errors since the real error
will be thrown back to the flow and will get handled and logged by the
normal error code path.

Extra logging has been added to `processEventsUntilFlowIsResumed`, just
in case an exception gets thrown out of the normal code path. We do not
want this exception to be swallowed as it can make it impossible to
debug the original error.
2020-08-10 13:09:43 +01:00
Dan Newton
0d5ee8b0fa
NOTICK Save exception for hospitalized session init errors (#6587)
Save the exception for flows that fail during session init when they are
kept for observation.

Change the exception tidy up logic to only update the flow's status if
the exception was removed.
2020-08-06 22:35:05 +01:00
Yiftach Kaplan
849d51c8cd
INFRA-505: Move integration tests to unit tests (#6530) 2020-08-06 15:16:27 +01:00
Kyriakos Tharrouniatis
0005317fec Align code with merging changes 2020-08-06 13:35:46 +01:00
Kyriakos Tharrouniatis
2afedeabb4 Merge branch 'release/os/4.6' into os_4.6-feature_pass_in_client_id_when_starting_a_flow 2020-08-06 13:21:45 +01:00
Dan Newton
3f31aeaa5f
CORDA-3822 Add CordaRPCOps.reattachFlowWithClientId (#6579)
Add `CordaRPCOps.reattachFlowWithClientId` to allow clients to reattach
to an existing flow by only providing a client id. This behaviour is the
same as calling `startFlowDynamicWithClientId` for an existing
`clientId`. Where it differs is `reattachFlowWithClientId` will return
`null` if there is no flow running or finished on the node with the same
client id.

Return `null` if record deleted from race-condition
2020-08-06 11:42:02 +01:00
filipesoliveira
8eaf237a27 Refactored the previous bug fix to minimize duplication by reusing an existing function.
Bear in mind that the condition in the previous code was (config == null) and now is (config == null || config.equals("")).
2020-08-06 11:15:19 +01:00
Will Vigor
7acc510534 CORDA-3602 Set a Checkpoint as incompatible if it can't be deserialised (#3653)
Update the compatible flag in the DB if the flowstate cannot be deserialised.

The most common cause of this problem is if a CorDapp has been upgraded
without draining flows from the node.

`RUNNABLE` and `HOSPITALISED` flows are restored on node startup so
the flag is set for these then. The flag can also be set when a flow
retries for some reason (see retryFlowFromSafePoint) in this case the
problem has been caused by another reason.
2020-08-06 11:00:02 +01:00
filipesoliveira
80d279a70e Fixed a bug which would make the "-f" flag to be ignored. 2020-08-06 10:51:23 +01:00
Will Vigor
4a828fcb99 ENT-5397 Pause individual running and hospitalised flows (#3564)
Added a newpause event to the statemachine which returns an Abort
continuation and causes the flow to be moved into the Paused flow Map.

Flows can receive session messages whilst paused.
2020-08-06 10:40:09 +01:00
Will Vigor
bbf5a93761 ENT-5396 Allow Retrying a Hospitalised Flow from the Statemachine (#3499)
Added functionality to the statemachine to enable retrying a Hospitalised flow without a node restart.
2020-08-06 10:11:15 +01:00
Dan Newton
a73dad00e2
CORDA-3850 Add a per flow lock (#6437)
Add a lock to `StateMachineState`, allowing every flow to lock
themselves when performing a transition or when an external thread (such
as `killFlow`) tries to interact with a flow from occurring at the same
time.

Doing this prevents race-conditions where the external threads mutate
the database or the flow's state causing an in-flight transition to
fail.

A `Semaphore` is used to acquire and release the lock. A `ReentrantLock`
is not used as it is possible for a flow to suspend while locked, and
resume on a different thread. This causes a `ReentrantLock` to fail when
releasing the lock because the thread doing so is not the thread holding
the lock. `Semaphore`s can be used across threads, therefore bypassing
this issue.

The lock is copied across when a flow is retried. This is to prevent
another thread from interacting with a flow just after it has been
retried. Without copying the lock, the external thread would acquire the
old lock and execute, while the fiber thread acquires the new lock and
also executes.
2020-08-06 09:51:42 +01:00
Kyriakos Tharrouniatis
5ba8477733
CORDA-3491 - Do not keep flow state in memory after a flow has finished (#6573)
Do not retain in database `checkpoint.flowState` for flows that have completed 
or failed and have started with a client id, after their lifetime.
2020-08-06 09:46:04 +01:00
Ross Nicoll
fd374bfc6d
CORDA-3943 Remove sleeps from flow reload tests (#6567)
* Remove use of Thread.sleep() FROM FlowReloadAfterCheckpointTest, instead relying on CountdownLatch to wait until the target number has been hit or a timeout occurs, so the thread can continue as soon as the target is hit.
* Replace use of hashmaps to a concurrent queue, to mitigate risk of complex threading issues.
2020-08-05 21:10:11 +01:00
Ross Nicoll
b779fb354c
CORDA-3948 Disable flaky test (#6572) 2020-08-05 14:16:15 +01:00
Christian Sailer
6f2ca8978d
Merge pull request #6534 from corda/feature/ENT-5273-unified-database-management
ENT-5273 unified database management
2020-08-05 14:09:07 +01:00
Dan Newton
f216853c3f
CORDA-3946 Make RetryFlowMockTest less flakey (#6570) 2020-08-05 13:10:35 +01:00
Christian Sailer
45618f346d
Code review fixes (#6571) 2020-08-05 12:48:17 +01:00
Kyriakos Tharrouniatis
5192a9a2dd
CORDA-3612 - Delete flow results/ exceptions once received by rpc client (#6566)
Enhance rpc acknowledgement method (`removeClientId`) to remove checkpoint 
from all checkpoint database tables.

Optimize `CheckpointStorage.removeCheckpoint` to not delete from all checkpoint
tables if not needed. This includes excluding the results (`DBFlowResult`) and 
exceptions (`DBFlowException`) tables.
2020-08-05 12:40:35 +01:00
Viktor Kolomeyko
9fd8107922
INFRA-570: Disable new SSL tests when running on JDK11 (#6560) 2020-08-05 10:02:23 +01:00
Ross Nicoll
ff5bdcb559
NOTICK Close node handles to reduce memory usage (#6557)
Note in theory this shouldn't make a difference, however given the pass rate of this PR I figure it's worth trying.
2020-08-05 08:54:28 +01:00
Kyriakos Tharrouniatis
5d42b8847c
CORDA-3681 - Store serialised exception in database for failed and hospitalized flows (#6539)
Integrate `DBFlowException` with the rest of the checkpoint schema, so now 
we are saving the flow's exception result in the database.

Making statemachine not remove `FAILED` flows' checkpoints from the 
database if they are started with a clientId.

Retrieve the DBFlowException from the database to construct a 
`FlowStateMachineHandle` future and complete exceptionally the flow's result 
future for requests (`startFlowDynamicWithClientId`) that pick FAILED flows , 
started with client id, of status Removed.

On killing a flow the client id mapping of the flow gets removed.

The storage serialiser is used for serialising exceptions. Note, that if an
exception cannot be serialised, it will not fail and will instead be stored
as a `CordaRuntimeException`. This could be improved in future
changes.
2020-08-04 16:33:44 +01:00
Christian Sailer
e6dfa4da39 Remove unused cmd line option 2020-08-04 14:20:41 +01:00
Christian Sailer
2888aa6b1d Merge remote-tracking branch 'origin/release/os/4.6' into christians/ENT-5273-updateandfixes 2020-08-04 14:19:46 +01:00
Ross Nicoll
25d1d61685
NOTICK Robustness improvements for DB race condition test (#6556)
Switch away from log monitoring to verify that DB race conditions are reported correctly, in an attempt to resolve a test instability issue.
2020-08-04 11:45:57 +01:00
Ross Nicoll
743dc507cc Merge remote-tracking branch 'origin/release/os/4.5' into rni/notick/4.5-4.6 2020-08-04 10:29:27 +01:00