Commit Graph

2924 Commits

Author SHA1 Message Date
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
Ross Nicoll
5d7060ec3a
CORDA-3901 Eliminate random reconnect test (#6446)
Remove a legacy test for RPC reconnection, which takes 5 minutes to run a random set of tests. This is expensive and low value.
2020-07-17 12:26:51 +01:00
Kyriakos Tharrouniatis
22d92d5ef0
CORDA-3809 Expose client side unique RPC ID for flow starts (#6307)
Introducing a new flow start method (`startFlowDynamicWithClientId`) passing in a `clientId`.

Once `startFlowDynamicWithClientId` gets called, the `clientId` gets injected into `InvocationContext` and also pushed to the logging context.

If a new flow starts with this method, then a < `clientId` to flow > pair is kept on node side, even after the flow's lifetime. If `startFlowDynamicWithClientId` is called again with the same `clientId` then the node identifies that this `clientId` refers to an existing < `clientId` to flow > pair and returns back to the rpc client a `FlowStateMachineHandle` future, created out of that pair.

`FlowStateMachineHandle` interface was introduced as a thinner `FlowStateMachine`. All `FlowStateMachine` properties used by call sites are moved into this new interface along with `clientId` and then `FlowStateMachine` extends it.

Introducing an acknowledgement method (`removeClientId`). Calling this method removes the < `clientId` to flow > pair on the node side and frees resources.
2020-07-16 10:52:08 +01:00
Adel El-Beik
2fa6b5a208
CORDA-3769: Switched attachments class loader cache to use caffeine (#6326)
* CORDA-3769: Switched attachments class loader cache to use caffeine with original implementation used by determinstic core.

* CORDA-3769: Removed default ctor arguments.

* CORDA-3769: Switched mapping function to Function type to avoid synthetic method being generated.

* CORDA-3769: Now using a cache created from NamedCacheFactory for the attachments class loader cache.

* CORDA-3769: Making detekt happy.

* CORDA-3769: The finality tests now check for UntrustedAttachmentsException which will actually happen in reality.

* CORDA-3769: Refactored after review comments.

* CORDA-3769: Removed the AttachmentsClassLoaderSimpleCacheImpl as DJVM does not need it. Also updated due to review comments.

* CORDA-3769: Removed the generic parameters from AttachmentsClassLoader.

* CORDA-3769: Removed unused imports.

* CORDA-3769: Updates from review comments.

* CORDA-3769: Updated following review comments. MigrationServicesForResolution now uses cache factory. Ctor updated for AttachmentsClassLoaderSimpleCacheImpl.

* CORDA-3769: Reduced max class loader cache size

* CORDA-3769: Fixed the attachments class loader cache size to a fixed default

* CORDA-3769: Switched attachments class loader size to be reduced by fixed value.
2020-07-16 09:58:36 +01:00
Dan Newton
ac4907a429
CORDA-3721 Finishing + retrying a flow cancels its future (#6454)
Cancel the future being run by a flow when finishing or retrying it. The
cancellation of the future no longer cares about what type of future it
is.

`StateMachineState` has the `future` field, which holds the 3
(currently) possible types of futures:
- sleep
- wait for ledger commit
- async operation / external operation

Move the starting of all futures triggered by actions into
`ActionFutureExecutor`.
2020-07-14 08:04:52 +01:00
Chris Rankin
e684cfd1e6
NOTICK: Avoid configuring more tasks in the deterministic modules. (#6452) 2020-07-13 10:33:23 +01:00
Christian Sailer
057a8d8ae9
NOTICK fix smoke tests and slow integration tests (#6422)
* Add schema migration to smoke tests
* Fix driver to work correctly for out-of-proc node with persistent database.
Co-authored-by: Ross Nicoll <ross.nicoll@r3.com>
2020-07-09 15:13:20 +01:00
Dan Newton
52240dc3d1
Merge pull request #6451 from corda/dan/os-4.5-to-4.6-merge-2020-07-08
NOTICK OS 4.5 to 4.6 merge 2020-07-08
2020-07-09 14:02:22 +01:00
LankyDan
8b231dc936 NOTICK Suppress detekt warning on StaffedFlowHospital 2020-07-08 16:18:16 +01:00
LankyDan
b6d649634f ENT-5196 handle errors during flow initialisation (#6378)
Update flow error handling tests after merging from earlier releases
2020-07-08 16:02:17 +01:00
LankyDan
b05c0f0cc1 ENT-5196 handle errors during flow initialisation (#6378)
Changes to `StaffedFlowHospital` after merging from earlier releases.
2020-07-08 14:43:24 +01:00
LankyDan
2204f44332 ENT-5196 handle errors during flow initialisation (#6378)
Changes to `TopLevelTransition` after merging from earlier releases.

When a flow is kept for observation and its checkpoint is saved as
HOSPITALIZED in the database, we must acknowledge the session init and
flow start events so that they are not replayed on node startup.

Otherwise the same flow will be ran twice when the node is restarted,
one from the checkpoint and one from artemis.
2020-07-08 14:41:29 +01:00
Chris Rankin
72938fdf38
CORDA-3892: Upgrade to Gradle 5.6.4 again, with build fixes. (#6448) 2020-07-08 11:34:25 +01:00
LankyDan
fdae04fc28 Merge branch 'release/os/4.5' into dan/os-4.5-to-4.6-merge-2020-07-08 2020-07-08 10:44:47 +01:00
Chris Rankin
16eb9dfc08
NOTICK: Fix some Gradle technical debt. (#6430) 2020-07-07 09:08:58 +01:00
Kyriakos Tharrouniatis
b619356bff
Reduce exception_message and stack_trace lengths in table node_flow_exceptions (#6432)
Reduce exception_message and stack_trace lengths in table node_flow_exceptions from 4000 to 2000 to fix Oracle failing with: 'ORA-00910: specified length too long for its datatype'
2020-07-07 09:07:01 +01:00
Dan Newton
9a8ae0fd32
CORDA-3841 Update session init flow error handling tests (#6431)
These tests were removed after doing a merge from 4.4. They needed
updating after the changes from 4.4 anyway. These have been included in
this change.

Also fix kill flow tests and send initial tests.
2020-07-07 08:47:09 +01:00
Dan Newton
a1e1bf4e6d
CORDA-3848 Uncaught exception hospitalises flow (#6377)
When an uncaught exception propagates all the way to the flow exception
handler, the flow will be forced into observation/hospitalised.

The updating of the checkpoints status is done on a separate thread as
the fiber cannot be relied on anymore. The new thread is needed to allow
database transaction to be created and committed. Failures to the status
update will be rescheduled to ensure that this information is eventually
reflected in the database.
2020-07-06 22:43:48 +01:00
Ryan Fowler
0d5bed5243
ENT-5131: Avoid NPE by throwing a catchable exception when openAttachment fails. (#6408) 2020-07-06 11:42:36 +01:00
Ross Nicoll
6aa19723e6
INFRA-417 Improve driver DSL test stability (#6415)
* Move log messages that are not useful in typical usage from info to debug level to reduce log spam.
* Add node startup check before attempting to connect.
2020-07-03 20:42:29 +01:00
Dan Newton
6bc2c79e23
NOTICK NodeBasedTest take in cordapps (#6424)
In enterprise, `AuthDBTests` picked up a schema from a unit test and
included it in the cordapp it builds. This schema does not have a
migration and therefore fails the integration tests.

`NodeBasedTest` now lets cordapps to be defined and passed in to avoid
this issue. It defaults to making a cordapp from the tests base
directory if none are provided.
2020-07-02 16:14:51 +01:00
Denis Rekalov
adc0879e8e
CORDA-3867: Add tests for AMQ_VALIDATED_USER (#6418)
* CORDA-3867: Add tests for AMQ_VALIDATED_USER

* CORDA-3867: detekt
2020-07-02 09:20:23 +01:00
Ross Nicoll
9f12e6bbc5
INFRA-433 Rebuild node config parsing tests (#6423)
Replace node configuration parsing tests with lighter weight equivalents which just parse the configuration rather than starting a full node.
2020-07-01 22:47:09 +01:00
LankyDan
c06830d851 Merge branch 'release/os/4.4' into dan/os-4.4-to-4.5-merge-2020-07-01
# Conflicts:
#	core/src/main/kotlin/net/corda/core/node/ServiceHub.kt
#	node/src/integration-test-slow/kotlin/net/corda/node/services/statemachine/StatemachineGeneralErrorHandlingTest.kt
#	node/src/integration-test-slow/kotlin/net/corda/node/services/statemachine/StatemachineKillFlowErrorHandlingTest.kt
#	node/src/integration-test/kotlin/net/corda/node/flows/FlowEntityManagerTest.kt
#	node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt
#	node/src/main/kotlin/net/corda/node/services/statemachine/TransitionExecutorImpl.kt
#	node/src/main/kotlin/net/corda/node/services/statemachine/interceptors/HospitalisingInterceptor.kt
2020-07-01 17:32:36 +01:00
Kyriakos Tharrouniatis
5499e2c050
ENT-5384 Rename MAX_SQL_IN_CLAUSE_SET (#6414)
Rename constant to `DEFAULT_SOFT_LOCKING_SQL_IN_CLAUSE_SIZE`
2020-07-01 09:31:12 +01:00
Dan Newton
efd633c7b9 CORDA-3722 withEntityManager can rollback its session (#6187)
* CORDA-3722 withEntityManager can rollback its session

Improve the handling of database transactions when using
`withEntityManager` inside a flow.

Extra changes have been included to improve the safety and
correctness of Corda around handling database transactions.

This focuses on allowing flows to catch errors that occur inside an
entity manager and handle them accordingly.

Errors can be caught in two places:

- Inside `withEntityManager`
- Outside `withEntityManager`

Further changes have been included to ensure that transactions are
rolled back correctly.

Errors caught inside `withEntityManager` require the flow to manually
`flush` the current session (the entity manager's individual session).
By manually flushing the session, a `try-catch` block can be placed
around the `flush` call, allowing possible exceptions to be caught.

Once an error is thrown from a call to `flush`, it is no longer possible
to use the same entity manager to trigger any database operations. The
only possible option is to rollback the changes from that session.
The flow can continue executing updates within the same session but they
will never be committed. What happens in this situation should be handled
by the flow. Explicitly restricting the scenario requires a lot of effort
and code. Instead, we should rely on the developer to control complex
workflows.

To continue updating the database after an error like this occurs, a new
`withEntityManager` block should be used (after catching the previous
error).

Exceptions can be caught around `withEntityManager` blocks. This allows
errors to be handled in the same way as stated above, except the need to
manually `flush` the session is removed. `withEntityManager` will
automatically `flush` a session if it has not been marked for rollback
due to an earlier error.

A `try-catch` can then be placed around the whole of the
`withEntityManager` block, allowing the error to be caught while not
committing any changes to the underlying database transaction.

To make `withEntityManager` blocks work like mini database transactions,
save points have been utilised. A new savepoint is created when opening
a `withEntityManager` block (along with a new session). It is then used
as a reference point to rollback to if the session errors and needs to
roll back. The savepoint is then released (independently from
completing successfully or failing).

Using save points means, that either all the statements inside the
entity manager are executed, or none of them are.

- A new session is created every time an entity manager is requested,
but this does not replace the flow's main underlying database session.
- `CordaPersistence.transaction` can now determine whether it needs
to execute its extra error handling code. This is needed to allow errors
escape `withEntityManager` blocks while allowing some of our exception
handling around subscribers (in `NodeVaultService`) to continue to work.
2020-06-30 11:54:16 +01:00
Dan Newton
f6b5737277
ENT-5196 handle errors during flow initialisation (#6378)
## Summary

This change deals with multiple issues:

* Errors that occur during flow initialisation.

* Errors that occur when handling the outcome of an existing flow error.

* Failures to rollback and close a database transaction when an error
occurs in `TransitionExecutorImpl`.

* Removal of create and commit transaction actions around retrying a flow.

## Errors that occur during flow initialisation

Flow initialisation has been moved into the try/catch that exists inside
`FlowStateMachineImpl.run`. This means if an error is thrown all the way
out of `initialiseFlow` (which should rarely happen) it will be caught 
and move into a flow's standard error handling path. The flow should 
then properly terminate.

`Event.Error` was changed to make the choice to rollback be optional. 
Errors during flow initialisation cause the flow to not have a open 
database transaction. Therefore there is no need to rollback.

## Errors that occur when handling the outcome of an existing flow error

When an error occurs a flow goes to the flow hospital and is given an 
outcome event to address the original error. If the transition that was 
processing the error outcome event (`StartErrorPropagation` and
`RetryFlowFromSafePoint`) has an error then the flow aborts and
nothing happens. This means that the flow is left in a runnable state.

To resolve this, we now retry the original error outcome event whenever 
another error occurs doing so.

This is done by adding a new staff member that looks for 
`ErrorStateTransitionException` thrown in the error code path of 
`TransitionExecutorImpl`. It then takes the last outcome for that flow 
and schedules it to run again. This scheduling runs with a backoff.

This means that a flow will continually retry the original error outcome
event until it completes it successfully.

## Failures to rollback and close a database transaction when an error occurs in `TransitionExecutorImpl`
   
Rolling back and closing the database transaction inside of 
`TransitionExecutorImpl` is now done inside individual try/catch blocks
as this should not prevent the flow from continuing.

## Removal of create and commit transaction actions around retrying a flow

The database commit that occurs after retrying a flow can fail which 
required some custom code just for that event to prevent inconsistent 
behaviour. The transaction was only needed for reading checkpoints from 
the database, therefore the transaction was moved into 
`retryFlowFromSafePoint` instead and the commit removed.

If we need to commit data inside of `retryFlowFromSafePoint` in the 
future, a commit should be added directly to `retryFlowFromSafePoint`. 
The commit should occur before the flow is started on a new fiber.
2020-06-30 11:50:42 +01:00
Tamas Veingartner
18cd24c2b4
NOTICK Ignore pagination large volume test as its completion is environment dependent and might cause issues in slower environments (#6420) 2020-06-30 10:12:31 +01:00
Denis Rekalov
e75dc9e415 Merge branch 'release/os/4.5' into denis/CORDA-3856-amqp-header-os-4.6 2020-06-29 13:13:48 +01:00
Denis Rekalov
7686ca2944 Merge branch 'release/os/4.4' into denis/CORDA-3856-amqp-header-os-4.5 2020-06-29 12:35:05 +01:00
pnemeth
6fc9f2eacf
EG-2854 Failing Test: net.corda.node.internal.NodeStartupCliTest.--nodeconf using absolute path will not be changed (#6393)
* EG-2854

Failing Test: net.corda.node.internal.NodeStartupCliTest.--nodeconf using absolute path will not be changed

* fix bug EG-2854

* PR comment
2020-06-29 09:40:12 +01:00
Denis Rekalov
3f03de6fbd
CORDA-3856: Add Artemis plugin for validating AMQP message header and type (#6407) 2020-06-29 09:23:29 +01:00
Dan Newton
516a4bf3a1
Merge pull request #6403 from corda/NOTICK-rfowler-merge-OS4.5-OS4.6-20200626
NOTICK rfowler merge os4.5 os4.6 20200626
2020-06-29 08:40:48 +01:00
Dan Newton
796e92b512
CORDA-3720 Extract locking of InnerState out of SMM (#6289)
The state machines state is held within `InnerState` which lived inside
the SMM. `InnerState` has been extracted out of the SMM to allow the SMM
to be refactored in the future. Smaller classes can now be made that
focus on a single goal as the locking of the state can be accessed from
external classes. To achieve this, pass the `InnerState` into the class
and request a lock if needed.

The locking of `InnerState` has been made a property of the `InnerState`
itself. It has a `lock` field that allows locks to be taken out when
needed.

An inline `withLock` function has been added to tidy up the code and not
harm performance.

Some classes have been made internal to prevent invalid usage of purely
node internal classes.

As part of this change, flow timeouts have been extracted out into
`FlowTimeoutScheduler`.
2020-06-26 12:48:15 +01:00
Ryan Fowler
31a1ee8803 Merge branch 'release/os/4.5' into NOTICK-rfowler-merge-OS4.5-OS4.6-20200626 2020-06-26 12:14:56 +01:00
Ryan Fowler
881d8d687c Merge branch 'release/os/4.4' into NOTICK-rfowler-merge-OS4.4-OS4.5-20200626 2020-06-26 09:52:16 +01:00
Ryan Fowler
ef582900cf
NOTICK Expand the regex to match what we already do in ENT (#6400) 2020-06-25 17:26:55 +01:00
Kyriakos Tharrouniatis
6ec2910f15
NOTICK Revert node_flow_exceptions type length back to 256 (#6395) 2020-06-25 09:40:58 +01:00
Chris Rankin
6485a025c7
ENT-5430: Increase test coverage when serializing Optional fields. (#6387) 2020-06-22 16:51:40 +01:00
Waldemar Zurowski
1a4efbac7f Merge branch 'release/os/4.5' into merge-45-to-46 2020-06-19 19:48:08 +01:00
pnemeth
d6cab0e131
EG-1557 - Configuration data from "include" section ignored while command line contains the path to config file without leading ./ (#6354)
Configuration data from "include" section ignored while command line contains the path to config file without leading ./
2020-06-19 10:32:55 +01:00
alicer3
e77f7a7546
center console message for registration (#6191) 2020-06-19 09:49:07 +01:00
LankyDan
56d0bbc036 CORDA-3841 Check isAnyCheckpointPersisted in startFlowInternal (#6351)
Only hit the database if `StateMachineState.isAnyCheckpointPersisted`
returns true. Otherwise, there will be no checkpoint to retrieve from the
database anyway. This can prevent errors due to a transient loss of
connection to the database.

Update tests after merging to 4.6
2020-06-18 16:15:15 +01:00
LankyDan
e8b17ff7b9 Merge branch 'release/os/4.5' into dan/os-4.5-to-4.6-merge-2020-06-18
# Conflicts:
#	node/src/main/kotlin/net/corda/node/services/persistence/DBCheckpointStorage.kt
#	node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt
2020-06-18 15:50:46 +01:00
Christian Sailer
4091fdc8b1
ENT-5264 Synchronise schema on the command line (#6353)
* Decouple DatabaseConfig and CordaPersistence etc.
* Add schema sync to schema migration + test
* Add command line parameters for synchronising schema
2020-06-18 11:38:46 +01:00
Chris Rankin
1ef62870bb Merge commit 'fe617818895edab334d80c5e8de2b38f39e67af6' into chrisr3-os44-merge 2020-06-17 18:54:54 +01:00
Chris Rankin
d0c0a1d9ba
ENT-5430: Fix deserialisation of commands containing generic types. (#6359) 2020-06-17 17:28:26 +01:00
James Higgs
24b0240d82
EG-2654 - Ensure stack traces are printed to the logs in error reporting (#6345)
* EG-2654 Ensure stack trace is printed to the logs in error reporting

* EG-2654 - Add a test case for exception logging
2020-06-17 14:32:12 +01:00
Dan Newton
7ab6a8f600
CORDA-3841 Check isAnyCheckpointPersisted in startFlowInternal (#6351)
Only hit the database if `StateMachineState.isAnyCheckpointPersisted`
returns true. Otherwise, there will be no checkpoint to retrieve from the
database anyway. This can prevent errors due to a transient loss of
connection to the database.
2020-06-16 09:22:26 +01:00
Tamas Veingartner
26d4bfb89f
CORDA-3578 add corda prefix to conf file names as original issue was … (#6322)
* CORDA-3578 add corda prefix to conf file names as original issue was having non-corda reference.conf files on classpath causes DriverDSLImp failure

it is better to have this naming convention and avoid further conflicts of conf files.

* fixed weird duplicates

* revert renaming changes for web-reference.conf and loadtest-reference.conf
2020-06-16 09:15:51 +01:00
Christian Sailer
836dd559e8
ENT-5316 split schema migration
* ENT-5273 Split schema migration into separate core and app schema migration, with separate command line flags
2020-06-15 15:52:31 +01:00
Christian Sailer
2c26f4db5d Merge remote-tracking branch 'origin/release/os/4.6' into christians/update-fb-2020-06-12 2020-06-15 09:02:55 +01:00
Christian Sailer
f1126226a8 Fix config tests (remove tx isolation level from config files) 2020-06-12 20:54:36 +01:00
Christian Sailer
35c661b9f6
Merge pull request #6341 from corda/chrisr3-45-merge
NOTICK: Merge from OS 4.5 up to ef00fa1.
2020-06-12 16:42:51 +01:00
Stefano Franz
64f0011a62
Make Checkpoint classes data classes (#6342)
* Make Checkpoint classes data classes

* tidy up null-checks for array equality
2020-06-12 16:35:32 +01:00
Christian Sailer
d00dc42b18 Merge remote-tracking branch 'origin/release/os/4.6' into christians/update-fb-2020-06-12 2020-06-12 14:51:43 +01:00
Chris Rankin
3f67e314c0 Merge commit 'ef00fa1388db37e155ab8cfed3763c14801f8aa9' into chrisr3-45-merge 2020-06-12 13:14:44 +01:00
James Higgs
6e349f298e
NOTICK - Ignore a potentially dodgy test (#6336) 2020-06-11 16:47:48 +01:00
James Higgs
ab023d0b07 Merge branch 'release/os/4.5' into jamesh/os-4.5-4.6-merge-11062020 2020-06-11 09:40:39 +01:00
James Higgs
58af87c988
EG-2225 - Create log directory in correct place with verbose flag set (#6321)
* Ensure logs directory is written to correct location
* Remove a superfluous set of log path property
* Add a unit test to catch bad log paths
* Address detekt issues
2020-06-10 10:46:57 +01:00
James Higgs
8b7275eb97
EG-2564 - Move printed error to logger (#6323) 2020-06-10 10:45:50 +01:00
Schife
fb184839f4 Merge branch 'release/os/4.5' of https://github.com/corda/corda into razvan-os-4.5-to-4.6-merge 2020-06-05 07:55:48 +01:00
nikinagy
caf5482244
ENT-4064, ENT-4608 - checking for unsigned cordapps in prod mode and checking the PV (#6291)
* checking for unsigned cordapps in prod mode and shutting down if it the contracts are not signed

* inheriting from CordaRuntimeException instead of Exception

* had the same tests twice, removed the shutdown for minimumplatformversion, modified some of the tests

* shut down when we get invalid platformversion and modified the test according to this

* making the message more accurate
2020-06-04 16:24:49 +01:00
Denis Rekalov
45614cf29e
Merge pull request #6266 from corda/denis/CORDA-3805-custom-migration-scripts
CORDA-3805: cut dependency from PersistentIdentityService for custom migration scripts
2020-06-04 14:20:26 +01:00
Dan Newton
f0d2c9fe71
NOTICK Correct StatemachineGeneralErrorHandlingtest (#6306) 2020-06-04 08:04:41 +01:00
Christian Sailer
98f62f60f1 Merge branch 'release/os/4.6' into christians/update-feat-20200502 2020-06-02 18:15:32 +01:00
Christian Sailer
2cb89897b4 Merge branch 'release/os/4.6' into christians/update-feat-20200502 2020-06-02 17:55:14 +01:00
Kyriakos Tharrouniatis
b8b462f68e
NOTICK Fix schema validation error for flow parameters (#6304)
Adding 'corda-blob' type, fixed 'Schema-validation: wrong column type'
2020-06-02 17:52:50 +01:00
williamvigorr3
0554c98d18
NOTICK Restrict to shell commands (#6303)
Remove shell command for pausing flows
2020-06-02 16:04:10 +01:00
James Higgs
04ddb267fd
[EG-2225] Prevent extra directories being created when relative base directories are specified (#6282)
Don't create an extra directory if a relative base path specified
2020-06-02 15:26:40 +01:00
Tamas Veingartner
9c4a76d367
CORDA-3176 Inefficient query generated on vault queries with custom p… (#6241)
* CORDA-3176 Inefficient query generated on vault queries with custom paging

a check added to avoid self joins
local postgres db tests were executed on large volume test data (50k states) to ensure that the DB optimizes the suspicious query and so it does not cuase performance issues.
A test added to check that a pagination query on large volume of sorted data is completed in a reasonable time

* foreach detekt fix
2020-06-02 10:33:59 +01:00
Christian Sailer
0ed6307577 Merge remote-tracking branch 'origin/release/os/4.6' into christians/update-feat-20200502 2020-06-02 09:03:11 +01:00
Denis Rekalov
98af7f10f9 CORDA-3805: Make custom migration scripts independent on the latest PersistentIdentityService schema 2020-06-01 16:22:21 +01:00
Rick Parker
9f2bd1dcae
Merge pull request #6295 from corda/feature/checkpoint_table_improvements
CORDA-3432 Feature/checkpoint table improvements
2020-06-01 11:31:13 +01:00
Kyriakos Tharrouniatis
4507b55857
CORDA-3725 Fix SQL deadlocks coming from soft locking states (#6287)
Adding to the query -explicitly- the flow's locked states resolved the SQL Deadlocks in SQL server. The SQL Deadlocks would come up  from `softLockRelease` when only the `lockId` was passed in as argument. In that case the query optimizer would use `lock_id_idx(lock_id, state_status)` to search and update entries in `VAULT_STATES` table. 

However, all rest of the queries would follow the opposite direction meaning they would use PK's `index(output_index, transaction_id)` but they would also update the `lock_id` column and therefore the `lock_id_idx` as well, because `lock_id` is a part of it. That was causing a circular locking among the different transactions (SQL processes) within the database.

To resolve this, whenever a flow attempts to reserve soft locks using their flow id (remember the flow id is always the flow id for the very first flow in the flow stack), we then save these states to the fiber. Then, upon releasing soft locks the fiber passes that set to the release soft locks query. That way the database query optimizer will use the primary key index of VAULT_STATES table, instead of lock_id_idx in order to search rows to update. That way the query will be aligned with the rest of the queries that are following that route as well (i.e. making use of the primary key), and therefore its locking order of resources within the database will be aligned with the rest queries' locking orders (solving SQL deadlocks).

* Fixed SQL deadlocks caused from softLockRelease, by saving locked states per fiber; NodeVaultService.softLockRelease query then uses VAULT_STATES PK index instead of lock_id_idx

Speed up SQL server by breaking down queries with > 16 elements in their IN clause, into sub queries with 16 elements max in their IN clauses

* Allow softLockedStates to remove states

* Add to softLockedStates only states soft locked under our flow id

* Fix softLockRelease not to take into account flowStateMachineImpl.softLockedStates when using lockId != ourFlowId

* Moved CriteriaBuilder.executeUpdate at the bottom of the file
2020-05-29 12:35:05 +01:00
Denis Rekalov
499c09e77b
Merge pull request #6285 from corda/denis/CORDA-3818-sync-identity-service
CORDA-3818: Synchronize OS implementation of PublicKeyToOwningIdentityCache with CE
2020-05-28 14:21:04 +01:00
Kyriakos Tharrouniatis
598228634f
CORDA-3608 Performance tune the new checkpoint schema (#6277)
Performance tuning of the new checkpoint schema;

- Checkpoint tables are now using `flowId` as join keys. 
- Indexes consist of a PK's index on `node_checkpoints(flow_id)` and then unique indexes on `node_checkpoint_blobs(flow_id)` and `node_flow_metadata(flow_id)`.
- Serialization of `checkpointState` is being done with `CHECKPOINT_CONTEXT` so that we can have compression. This is needed when messages get passed into `checkpointState.sessions` therefore `checkpointState` grows in size upon serialized and 
saved into the database.

* Deserialize checkpointState with CHECKPOINT_CONTEXT

* Align tests with schema update; We cannot add and update a checkpoint in the same session now, ends up with hibernate complaining: two different objects with same identifier

* Fix indentation and format

* Ignore tests that assert DBFlowResult or DBFlowException

* Set DBFlowCheckpoint.blob to null whenever the flow errors or hospitalizes; this way we save an extra SELECT in such cases;

* Fix test; cleared Hibernate session, it would fail at checkpoint with 'org.hibernate.NonUniqueObjectException'

* Changing VARCHAR to NVARCHAR

* Rename v17 liquibase scripts to v19 to resolve collision with ENT v17 scripts
2020-05-27 16:46:56 +01:00
Chris Rankin
6e156bc0ea Merge commit '6ebc6e9b16575a7afbb781b0d93a8f04b3affba5' into chrisr3-45-merge 2020-05-27 10:40:36 +01:00
Denis Rekalov
5afdb63c94 CORDA-3818: Synchronize OS implementation of PublicKeyToOwningIdentityCache with CE 2020-05-26 16:10:14 +01:00
Chris Rankin
6ebc6e9b16
CORDA-3750: Reimplement Corda's Crypto object for use inside the sandbox. (#6193)
* CORDA-3750: Use hand-written sandbox Crypto object that delegates to the node.

* CORDA-3750: Add integration test for deterministic CashIssueAndPayment flow.

* Tidy up generics for Array instances.

* Upgrade to DJVM 1.1-RC04.
2020-05-26 15:46:29 +01:00
Dan Newton
330a95cb68
ENT-4627 Log transaction context missing exception (#6278)
When a flow is missing its database transaction the _real_ stacktrace
of the exception is missing in the logs. This is due to the normal error
handling path way does not work due the transaction being missing. When
it goes to process the next error event (due to the original transaction
context missing error) it will fail for the same error as it needs the
context to be able to process the error event.

The extra logging should help diagnose future errors.
2020-05-26 11:32:42 +01:00
Christian Sailer
70f1ea0a9d
ENT-5258 db schema set-up only via command line flag (#6280)
Removing the ability to initialise schema from the node config, and add a new sub-command to initialise the schema (that does not do anything else and exits afterwards).
Also adding a command line flag that allow app schema to be maintained by hibernate for legacy cordapps, tests or rapid development.
Patching up mock net and driver test frameworks so they create the required schemas for tests to work, defaulting schema migration and hibernate schema management to true to match pre-existing behaviour.
Modified network bootstrapper to run an initial schema set-up so it can register nodes.
2020-05-22 16:27:10 +01:00
Kyriakos Tharrouniatis
57b1a5e0fc
ENT-5339 Failing tests against Oracle in VaultObserverExceptionTest (#6275)
* Fix erroneous sql statement for oracle; It was failing tests with 'ORA-00933: SQL command not properly ended'

* Fixed flaky test; it didn't wait for counter party flow to get hospitalized as the test implied
2020-05-22 10:15:51 +01:00
Rick Parker
67298eb780
Merge pull request #6270 from corda/nnagy-os-4.5-os-4.6-20200520
Nnagy os 4.5 os 4.6 20200520
2020-05-21 13:19:58 +01:00
Viktor Kolomeyko
31612901cf
CORDA-3800: Flaky ProtonWrapperTests test investigation (#6258) 2020-05-21 12:33:56 +01:00
nikinagy
301fc9f928 Merge branch 'release/os/4.5' into nnagy-os-4.5-os-4.6-20200520 2020-05-20 10:38:45 +01:00
nikinagy
938d038c97
ENT-5278 - add missed checks for empty lists (#6261)
* add missed checks for empty lists

* adding missing brackets

* adding missing timeout
2020-05-19 16:55:09 +01:00
Dan Newton
36a11e868a
NOTICK Fix timing issue in FlowIsKilledTest (#6264)
Also remove `Configurator` that seems to fail on some agents.
2020-05-19 16:54:34 +01:00
williamvigorr3
eb52de1b40
CORDA-3490 Add option to start node without starting checkpointed flows (#6136)
Added command-line option: `--pause-all-flows` to the Node to control this.
This mode causes all checkpoints to be set to status PAUSED when the
state machine starts up (in StartMode.Safe mode). 

Changed the state machine so that PAUSED checkpoints are loaded into
memory (the checkpoint is deserialised but the flow state is left serialised)
but not started.

Messages from peers are queued whilst the flow is paused and processed
once the flow is resumed.
2020-05-19 16:27:41 +01:00
nikinagy
cc8ce3ca99
empty list checks (#6262) 2020-05-19 14:04:19 +01:00
Adel El-Beik
b9b0ca58e3 Merge remote-tracking branch 'origin/release/os/4.5' into adel/merge-from-4.5 2020-05-15 10:23:17 +01:00