Commit Graph

2913 Commits

Author SHA1 Message Date
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
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
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
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
Ross Nicoll
1ca9b998de
NOTICK Replace example URL with an unresolvable version (#6555)
Replace example URL with an unresolvable version to avoid issues with network failures causing
the test to fail, i.e. https://ci02.dev.r3.com/job/Corda-Enterprise/job/Corda-ENT-Release-Branch-Tests/job/enterprise/job/release%252Fent%252F4.6/127/testReport/net.corda.node.services.config/NodeConfigurationImplTest/compatibilityZoneURL_populates_NetworkServices/
2020-08-03 22:11:26 +01:00
Tamas Veingartner
0b7fdbb35d
CORDA-3663 Remove dummy package names (#6553)
Dummy package names cause build failure as they are not found on the classpath when trying to import them. Now that empty package name list is allowed, the dummy names are removed.
2020-08-03 19:09:30 +01:00
Christian Sailer
71a6081ec8 Fix new integration tests to not use hibernate schema modification. 2020-08-03 18:50:36 +01:00
Christian Sailer
89759510ae Merge remote-tracking branch 'origin/release/os/4.6' into christians/ENT-5273-update-from-os-4.6-20200803 2020-08-03 16:28:20 +01:00
Tamas Veingartner
85be50779b
CORDA-3663 MockServices crashes when two of the provided packages to … (#6472)
* CORDA-3663 MockServices crashes when two of the provided packages to scan are deemed empty in 4.4 RC05

this happends when a given package is not found on the classpath. Now it is handled and an exception is thrown

* replace dummy package names in tests with valid ones

* allow empty package list for CustomCordapps and exclude those from the created jars

* detekt fix

* always true logic fix

* fix to check for empty packages instead of empty classes

* fix for classes and fixups

* logic refactor because of detekt stupidity

* PR related minor refactors
2020-08-03 09:19:48 +01:00
Dan Newton
c288073e7c
Merge pull request #6524 from corda/ENT-5532-retrying-flow-with-sessions-to-close
ENT-5532 Terminate sessions after original io request
NOTICK Resume flow when wrong message received
2020-07-31 17:08:43 +01:00
LankyDan
82bcde573b NOTICK Resume flow when wrong message received
When an incorrect message is received, the flow should resume to allow
it to throw the error back to user code and possibly cause the flow to
fail.

For now, if an `EndSessionMessage` is received instead of a
`DataSessionMessage`, then an `UnexpectedFlowEndException` is thrown
back to user code. Allowing it to correctly re-enter normal flow error
handling.

Without this change, the flow will hang due to it failing while creating
a transition which exists outside of the general state machine error
handling code path.
2020-07-31 14:28:57 +01:00
LankyDan
39dbe22c9d ENT-5532 Terminate sessions after original io request
Sessions are now terminated after performing the original
`FlowIORequest` passed into `StartedFlowTransition`, instead of before.
This is done by scheduling an `Event.TerminateSessions` if there are
sessions to terminate when performing a suspending event.

Originally this was done by hijacking a transition that is trying to
perform a `StartedFlowTransition`, terminating the sessions and then
scheduling another `Event.DoRemainingWork` to perform the original
transition. This introduced a bug where, another event (from a external
message) could be placed onto the queue before the
`Event.DoRemainingWork` could be added. In most scenarios, that should
be ok. But, if a flow is retrying (while in an uninitiated state) and
this occurs the flow could fail due to being in an unexpected state.

Terminating the sessions after performing the original transition
removes this possibility. Meaning that a restarting flow will always
perform the transition they supposed to do (based on the called
suspending event).
2020-07-31 12:37:44 +01:00
James Higgs
250ed8a21a
Merge pull request #6533 from corda/eg-177merge
EG-177   Network Parameter Hotloading
2020-07-31 09:45:23 +01:00
Viktor Kolomeyko
c498c5bf7c
CORDA-3871: New integration test for handshake timeout in AMQPClient (#6519)
* CORDA-3871: Import external code

Compiles, but does not work for various reasons

* CORDA-3871: More improvements to imported code

Currently fails due to keystores not being found

* CORDA-3871: Initialise keystores for the server

Currently fails due to keystores for client not being found

* CORDA-3871: Configure certificates to client

The program started to run

* CORDA-3871: Improve debug output

* CORDA-3871: Few more minor changes

* CORDA-3871: Add AMQClient test

Currently fails due to `localCert` not being set

* CORDA-3871: Configure server to demand client to present its certificate

* CORDA-3871: Changes to the test to make it pass

ACK status is not delivered as server is not talking AMQP

* CORDA-3871: Add delayed handshake scenario

* CORDA-3871: Tidy-up imported classes

* CORDA-3871: Hide thread creation inside `ServerThread`

* CORDA-3871: Test description

* CORDA-3871: Detekt baseline update

* CORDA-3871: Trigger repeated execution of new tests

To make sure they are not flaky

* CORDA-3871: Improve robustness of the newly introduced tests

* CORDA-3871: Improve robustness of the newly introduced tests

* CORDA-3871: New tests proven to be stable - reduce number of iterations to 1

* CORDA-3871: Adding Alex Karnezis to the list of contributors
2020-07-31 09:26:32 +01:00
Ross Nicoll
68feb1c35f
CORDA-3932 Correct race condition in FlowVersioningTest (#6536)
Correct race condition in FlowVersioningTest where the last message is read (and the session close can be triggered)
before one side has finished reading metadata from the session.
2020-07-31 08:32:20 +01:00
Christian Sailer
81d68abe7e Merge remote-tracking branch 'origin/release/os/4.6' into christians/ENT-5273-update-fb-from-os.4.6 2020-07-30 18:39:04 +01:00
Peter Nemeth
777be6c11a Merge branch 'feature/EG-177' of https://github.com/corda/corda into feature/EG-177 2020-07-30 16:20:01 +01:00
pnemeth
2a27f3ac37
EG-2055 Implement network parameters hotloading (#6517)
* Implement network parameters hotloading

* fixed failing unit test

* PR comments

* PR comments

* added integr tests+ renamed updater to hotloader

* moved exiting logic out of hotloader

* extra tests

* latest PR comments

* refactor

* address detekt/suppress if more significant refactoring needed

* extra tests

* addressed PR comments

* detekt

* formatting
2020-07-30 16:02:33 +01:00
Ross Nicoll
fd5472b053
NOTICK Remove memory leak endurance test (#6514)
Remove memory leak endurance test as it spends 8 minutes testing a single failure case that's not end user visible,
and ultimately manifests elsewhere in test failures (which is where this came from in the beginning). It was a good
idea to confirm the change fixed the issue, but this isn't critical enough to retain.
2020-07-30 15:39:28 +01:00
Yiftach Kaplan
0bedbd8c75
INFRA-530: Start notary node in process (#6521) 2020-07-29 15:47:45 +01:00
Dan Newton
c2fd8253ea
CORDA-3777 Reload after every checkpoint (#6494)
Enable reloading of a flow after every checkpoint is saved. This
includes reloading the checkpoint from the database and recreating the
fiber.

When a flow and its `StateMachineState` is created it checks the node's
config to see if the `reloadCheckpointAfterSuspend` is set to true. If it is
it initialises `StateMachineState.reloadCheckpointAfterSuspendCount`
with the value 0. Otherwise, it remains `null`.

This count represents how many times the flow has reloaded from its
checkpoint (not the same as retrying). It is incremented every time the
flow is reloaded.

When a flow suspends, it processes the suspend event like usual, but
it will now also check if `reloadCheckpointAfterSuspendCount` is not
`null` (that it is activated) and process a 
`ReloadFlowFromCheckpointAfterSuspend`event, if and only if 
`reloadCheckpointAfterSuspendCount` is greater than
`CheckpointState.numberOfSuspends`.

This means idempotent flows can reload from the start and not reload
again until reaching a new suspension point.

Flows that skip checkpoints can reload from a previously saved
checkpoint (or from the initial checkpoint) and will continue reloading
on reaching the next new suspension point (not the suspension point that
it skipped saving).

If the flow fails to deserialize the checkpoint from the database upon
reloading a `ReloadFlowFromCheckpointException` is throw. This causes
the flow to be kept for observation.
2020-07-28 16:27:51 +01:00
Stefan Iliev
52cbe04b8c
EG-2375 - batching notary open sourcing. (#6507) 2020-07-28 15:50:19 +01:00
Dimitris Gounaris
1e6be340eb
CORDA-3844: bulk node infos request (#6411)
* CORDA-3844: Add new functions to network map client

* CORDA-3844: Apply new fetch logic to nm updater

* CORDA-3844: Fix base url and warnings

* CORDA-3844: Change response object and response validation

In order to make sure that the returned node infos are not maliciously modified, either a signed list response
or a signed reference object would need to be provided. As providing a signed list requires a lot of effort from NM and Signer services,
the signed network map is provided instead, allowing nodes to validate that the list provided conforms to the entries of the signed network map.

* CORDA-3844: Add clarifications and comments

* CORDA-3844: Add error handling for bulk request

* CORDA-3844: Enhance testing

* CORDA-3844: Fix detekt issues

* EG-3844: Apply pr suggestions
2020-07-28 15:02:53 +01:00
Dimos Raptis
f2336f397d
CORDA-3506 - Add test for session close API (#6512) 2020-07-28 10:20:24 +01:00
Christian Sailer
19e11619b4 Remove unused import 2020-07-23 17:59:54 +01:00
Ryan Fowler
2ca10464b7
CORDA-3845: Update BC, log4j, slf4j (#6464)
* CORDA-3845: Update BC to 1.64

* CORDA-3845: Upgraded log4j to 2.13.3

* We can remove the use of Manifests from the logging package so that when _it_ logs it doesn't error on the fact the stream was already closed by the default Java logger.

* Some more tidy up

* Remove the logging package as a plugin

* latest BC version

* Remove old test

* fix up

* Fix some rebased changes to log file handling

* Fix some rebased changes to log file handling

* Update slf4j too

Co-authored-by: Adel El-Beik <adel.el-beik@r3.com>
2020-07-23 16:37:29 +01:00
Yiftach Kaplan
4acf41ea3d
INFRA-477: Start nodes in parallel when possible (#6460)
Co-authored-by: Ross Nicoll <ross.nicoll@r3.com>
2020-07-23 16:35:34 +01:00
Christian Sailer
db94f65d8a Merge remote-tracking branch 'origin/release/os/4.6' into christians/ENT-5273-update-from-os-4.6 2020-07-23 14:02:18 +01:00
Joseph Zuniga-Daly
c33720c73d
CORDA-3717: Apply custom serializers to checkpoints (#6392)
* CORDA-3717: Apply custom serializers to checkpoints

* Remove try/catch to fix TooGenericExceptionCaught detekt rule

* Rename exception

* Extract method

* Put calls to the userSerializer on their own lines to improve readability

* Remove unused constructors from exception

* Remove unused proxyType field

* Give field a descriptive name

* Explain why we are looking for two type parameters when we only use one

* Tidy up the fetching of types

* Use 0 seconds when forcing a flow checkpoint inside test

* Add test to check references are restored correctly

* Add CheckpointCustomSerializer interface

* Wire up the new CheckpointCustomSerializer interface

* Use kryo default for abstract classes

* Remove unused imports

* Remove need for external library in tests

* Make file match original to remove from diff

* Remove maySkipCheckpoint from calls to sleep

* Add newline to end of file

* Test custom serializers mapped to interfaces

* Test serializer configured with abstract class

* Move test into its own package

* Rename test

* Move flows and serializers into their own source file

* Move broken map into its own source file

* Delete comment now source file is simpler

* Rename class to have a shorter name

* Add tests that run the checkpoint serializer directly

* Check serialization of final classes

* Register as default unless the target class is final

* Test PublicKey serializer has not been overridden

* Add a broken serializer for EdDSAPublicKey to make test more robust

* Split serializer registration into default and non-default registrations. Run registrations at the right time to preserve Cordas own custom serializers.

* Check for duplicate custom checkpoint serializers

* Add doc comments

* Add doc comments to CustomSerializerCheckpointAdaptor

* Add test to check duplicate serializers are logged

* Do not log the duplicate serializer warning when the duplicate is the same class

* Update doc comment for CheckpointCustomSerializer

* Sort serializers by classname so we are not registering in an unknown or random order

* Add test to serialize a class that references itself

* Store custom serializer type in the Kryo stream so we can spot when a different serializer is being used to deserialize

* Testing has shown that registering custom serializers as default is more robust when adding new cordapps

* Remove new line character

* Remove unused imports

* Add interface net.corda.core.serialization.CheckpointCustomSerializer to api-current.txt

* Remove comment

* Update comment on exception

* Make CustomSerializerCheckpointAdaptor internal

* Revert "Add interface net.corda.core.serialization.CheckpointCustomSerializer to api-current.txt"

This reverts commit b835de79bd.

* Restore "Add interface net.corda.core.serialization.CheckpointCustomSerializer to api-current.txt""

This reverts commit 718873a4e9.

* Pass the class loader instead of the context

* Do less work in test setup

* Make the serialization context unique for CustomCheckpointSerializerTest so we get a new Kryo pool for the test

* Rebuild the Kryo pool for the given context when we change custom serializers

* Rebuild all Kryo pools on serializer change to keep serializer list consistent

* Move the custom serializer list into CheckpointSerializationContext to reduce scope from global to a serialization context

* Remove unused imports

* Make the new checkpointCustomSerializers property default to the empty list

* Delegate implementation using kotlin language feature
2020-07-22 17:31:59 +01:00
Dan Newton
a41152edf6
CORDA-3899 Refactor flow's transient fields (#6441)
Refactor `FlowStateMachineImpl.transientValues` and
`FlowStateMachineImpl.transientState` to stop the fields from exposing
the fact that they are nullable.

This is done by having private backing fields `transientValuesReference`
and `transientStateReference` that can be null. The nullability is still
needed due to serialisation and deserialisation of flow fibers. The
fields are transient and therefore will be null when reloaded from the
database.

Getters and setters hide the private field, allowing a non-null field to
returned.

There is no point other than in `FlowCreator` where the transient fields
can be null. Therefore the non null checks that are being made are
valid.

Add custom kryo serialisation and deserialisation to `TransientValues`
and `StateMachineState` to ensure that neither of the objects are ever
touched by kryo.
2020-07-22 16:19:20 +01:00
Yiftach Kaplan
a03fb8c6fd
INFRA-438: Close session factory before closing the locator (#6477) 2020-07-21 18:10:09 +01:00
Christian Sailer
377c3f9d78 Merge remote-tracking branch 'origin/release/os/4.6' into christians/ENT-5273-update-from-os-4.6 2020-07-21 14:17:27 +01:00
Dimos Raptis
7261fa690f
CORDA-3506 - Implement session close operations (#6357) 2020-07-21 13:26:11 +01:00
Viktor Kolomeyko
234ac2c246 Merge remote-tracking branch 'origin/release/os/4.5' into vkolomeyko/os-4.5-os-4.6-merge 2020-07-21 10:29:07 +01:00
Viktor Kolomeyko
1c48418904
NOTICK: Remove relaxedThoroughness variable (#6483)
It is:
a. No longer works in Jenkins
b. May result spawning 100s of process that kill Windows build. Evidence: https://ci02.dev.r3.com/blue/organizations/jenkins/Corda-Enterprise%2FCorda-ENT-MS-Win-Compatibility%2Fenterprise/detail/PR-3553/25/pipeline/
2020-07-21 09:58:29 +01:00
Kyriakos Tharrouniatis
5fef0726a2
Add missing 'Suspendable' annotations to suspending methods (#6480) 2020-07-20 15:09:26 +01:00
Ryan Fowler
d4444e520a
ENT-5140: Tighten network parameters checks (#6390)
* ENT-5140: Tighten network parameters checks
2020-07-20 11:26:27 +01:00
jakubbielawa
3721b7c701
Decrease the ring buffer size (#6470) 2020-07-20 11:14:23 +01:00
Dimos Raptis
e5a8351dc3
ENT-5437 - Add test for sendAll with multiple sessions from the same party (#6476) 2020-07-20 11:13:49 +01:00
Oliver Knowles
a500084d38
CORDA-3201 - Enforce separate key for notary identity (#6308) 2020-07-20 10:59:08 +01:00
Yiftach Kaplan
e6d5842a23
INFRA-482: Correct exception caught testing for node death (#6471) 2020-07-17 13:57:40 +01:00