-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command dedup: add columns to completions in append-only schemas [KVL-1057] #10652
Command dedup: add columns to completions in append-only schemas [KVL-1057] #10652
Conversation
CHANGELOG_BEGIN CHANGELOG_END
…letions/proto-additions
CHANGELOG_BEGIN CHANGELOG_END
@digital-asset/kv-participant Could you please have a first stab at the schema changes? |
…fo-to-completions
...in/resources/db/migration/postgres-appendonly/V108_add_deduplication_info_to_completions.sql
Outdated
Show resolved
Hide resolved
...in/resources/db/migration/postgres-appendonly/V108_add_deduplication_info_to_completions.sql
Outdated
Show resolved
Hide resolved
...gration-api/src/main/resources/db/migration/h2database-appendonly/V1__Append_only_schema.sql
Outdated
Show resolved
Hide resolved
...in/resources/db/migration/postgres-appendonly/V108_add_deduplication_info_to_completions.sql
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of additional things I am not sure about:
- Do we have a policy for the position of newly added columns?
- I couldn't find another instance of duration, is the double i64+i32 column (as in protobuf) OK?
AFAIK no policy regarding position ATM
Do you need such precision? Wouldn't be seconds or millis enough (resulting in one bigint column)? |
General comment to this PR
|
@nmarton-da Thanks for the feedback; the intention was to break down the work in small, separate reviews as much as possible, starting with the ones requiring the most feedback (like the ledger API proto and the DB schema, the latter purely on a technical level initially). |
Good point, I couldn't find any mention of resolution restrictions w.r.t. the API type (i.e., protobuf's). @SamirTalwar-DA Do you know anything more here? |
I think the schema change and the code which works with that should be same unit in terms of work / mergable / PR. Don't get me wrong please, small PRs is a very good thing, but there must be a PR which is too small :) I claim making db changes without the supporting code falls into the too small category. Also don't get me wrong please on the other end neither: I am not saying that because that should belong together with something else, then everything needs to belong together: feel free to maintain granular changes later as you see fit! TLDR:
|
…fo-to-completions
val (deduplicationTimeSeconds, deduplicationTimeNanos) = | ||
completionInfo.optDeduplicationPeriod | ||
.flatMap { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val (deduplicationTimeSeconds, deduplicationTimeNanos) = | |
completionInfo.optDeduplicationPeriod | |
.flatMap { | |
val (deduplicationTimeSeconds, deduplicationTimeNanos, deduplicationOffset) = | |
completionInfo.optDeduplicationPeriod | |
.flatMap { |
You are also calling completionInfo.optDeduplicationPeriod.flatMap
below, you could move it up here to have a single place to handle all three variants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...ant-integration-api/src/test/lib/scala/platform/store/backend/StorageBackendTestValues.scala
Outdated
Show resolved
Hide resolved
@@ -41,6 +41,7 @@ private[backend] object StorageBackendTestValues { | |||
ParameterStorageBackend.IdentityParams(someLedgerId, someParticipantId) | |||
val someParty: Ref.Party = Ref.Party.assertFromString("party") | |||
val someApplicationId: Ref.ApplicationId = Ref.ApplicationId.assertFromString("application_id") | |||
val someSubmissionId: String = "submission_id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this a Ref.SubmissionId
? All other some*
values are properly typed as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val dtos = UpdateToDbDto(someParticipantId, valueSerialization, compressionStrategy)( | ||
someOffset | ||
)(update).toList | ||
forAll(deduplicationPeriods) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could have left "handle TransactionAccepted (single create node)"
alone and added a new test "handle TransactionAccepted (all deduplication data)"
. This would make it more clear what the purpose of each test is, at the cost of duplicated code.
maybeDeduplicationTimeNanos: Option[Int], | ||
maybeDeduplicationTimeSeconds: Option[Long], | ||
): Completion.DeduplicationPeriod = | ||
// The only invariant tha should hold, considering legacy data, is that either |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// The only invariant tha should hold, considering legacy data, is that either | |
// The only invariant that should hold, considering legacy data, is that either |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…torageBackendTemplate calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks solid.
Thanks for your patience regarding the back and forth-s
@@ -60,4 +81,82 @@ private[platform] object CompletionFromTransaction { | |||
recordTime = Some(fromInstant(recordTime)), | |||
offset = Some(LedgerOffset.of(LedgerOffset.Value.Absolute(offset.toApiString))), | |||
) | |||
|
|||
private def toApiCompletion( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quite some branches here, how about adding some unit tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's mostly because of scalapb plus proto's "non-optional optionals"; I simplified it further in 2749c75 and I think a unit test at this level doesn't add much value because it's very thin logic and the test would basically duplicate it in order to check it. I think testing the CompletionFromTransaction
unit at its interface (i.e., acceptedCompletion
and rejectedCompletion
) is in a similar situation as it just delegates to the private toXXX
utilities.
Also, this logic should already have full coverage by the DB-level integration test cases in StorageBackendTestsCompletions
. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge this as soon as the build passes and we'll deal with further improvements in a separate PR, if need be.
case DeduplicationDuration(duration) => | ||
(None, Some(duration.getSeconds), Some(duration.getNano)) | ||
} match { | ||
case Some(value) => value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about .getOrElse((None, None, None)) instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR has been created by a script, which is not very smart and does not have all the context. Please do double-check that the version prefix is correct before merging. @aherrmann-da is in charge of this release. Commit log: ``` f058c2f DPP-368 clean up flags (#10711) 90ad24f [Divulgence pruning] Prune immediate divulgence [DPP-513] (#10691) 183934b Command dedup: add columns to completions in append-only schemas [KVL-1057] (#10652) 27c1333 LF: Drop outdated TODOs (#10725) 9be577a Enable pruning in the sandbox-classic when the append-only schema is used [DPP-567] (#10708) 9f072ae Ledger-API Conformance test for Contract ID V0 (#10717) 867547c DPP-368 enable append-only flag in sandbox (#10710) bdc511e [DPP-438] Change open-ended metric names into static ones (by removing partyName part) (#10706) 0c82006 [Divulgence pruning] Prune all divulged contracts only after migration offset [DPP-483] (#10661) 2555dbb Use soft references for values in the caches (#10715) 7fd5906 Add LedgerClientWithoutLedgerId next to the LedgerClient (#10681) 856c69c participant-integration-api: Increase a test timeout. (#10721) b86d07d remove non functioning oracle json array indices (#10720) f5e1756 sandbox-classic: Remove default parameters in `SqlLedger.Owner`. (#10718) 9ef3377 LF: Update specification with Contract ID Comparability check (#10703) e5c4734 enable JSON search index on Oracle by default (#10539) 1ded42f [DPP-418] Protect TLS keys - follow-up cleanup (#10696) 3fcd986 Introduce a new `Offset` format [KVL-1063] (#10668) a5781a6 update NOTICES file (#10714) 8985505 participant-integration-api: Use deadlines, not deduplication times, for expiring trackers. [KVL-1009] (#10704) 65025c2 sandbox-classic: Add ErrorInfo metadata for rejections. [KVL-1048] (#10707) 97bda3c LF: V1 Contract ID check in Preprocessor (#10687) c2f90ef Add CLI option to force disabling of participant deduplication (#10698) 6016633 Construct ParsedModule directly in Daml Repl (#10701) bbdf16a DPP-368 unhide append-only CLI flags (#10697) a41b134 Use the tracker retention period as the maximum expiry time. [KVL-1009] (#10700) e750ba5 Make warning less scary. (#10699) 5f120bd rotate release duty after 1.17.0-snapshot.20210824.7647.0.640fb683 (#10660) a17253f DPP-535 Verify postgres version (#10577) 301ce53 participant-integration-api: Add tests for ApiCommandService. [KVL-1009] (#10689) bd01a21 [DPP-418] Protect Participant TLS keys (#10629) 7ee1324 update NOTICES file (#10695) 7c392f3 update NOTICES file (#10693) 3db654e update NOTICES file (#10690) eff09c0 ledger-api-client: Wrap command submissions in a new class. [KVL-1009] (#10683) d54adb2 Ledger-API: Conformance tests for contract IDs suffixing (#10654) aa2e869 [Divulgence pruning] Pass divulged contract arguments through kvutils Write/ReadService [DPP-535] (#10598) 1a78313 Disable DeeplyNestedValueIT suite against canton in Daml repo (#10686) b5f9be3 participant-integration-api: Standardize tracker retention naming. (#10682) 2aa632e ledger-on-sql: Do not increment the dispatcher head on start. (#10684) eabb19d [ledger-api] Add deduplication_duration to deduplication period [kvl-1047] (#10676) 96ad9b5 [Divulgence pruning] All divulgence events pruning [DPP-483] (#10634) 0b7980d Update rules_haskell (#10674) 284edfc Fix FlywayMigrations datasource (#10666) adbe65f Document ActionFail vs CanAbort (#10657) 52e7a6d update compat versions for 1.17.0-snapshot.20210824.7647.0.640fb683 (#10667) f42e6b6 Expose pending contracts in triggers (#10672) 7cc6989 Add multiple ways of specifying deduplication [KVL-1047] (#10601) 53be19f participant-integration-api: Ensure that all waiting, failed, and closed trackers are cleaned up. (#10662) b27cde6 participant-integration-api: Move tracker code around, and tidy up tests. (#10663) fc9d359 Drop alternative rules from dlint config (#10646) 5204d3c Include committers in PartialTransaction root context (#10665) 387c68b Normalize transaction values within the engine (#10648) 430c1cc release 1.17.0-snapshot.20210824.7647.0.640fb683 (#10659) ef239fd participant-integration-api: Move `TrackerMap` code around. [KVL-1009] (#10653) ``` Changelog: ``` - [Sandbox] - Participant pruning is enabled in the sandbox-classic when the append-only schema is used - [Ledger Client Scala Bindings] A new variant of the LedgerClient class was added called `LedgerClientWithoutLedgerId`. This class does not need a ledger id at initialization. It was added to allow skipping any checks at initialization for use cases where either the ledger id is not known at initalization or no valid token can be fed at initialization for checking the ledger id. Furthermore for each classes `ActiveContractSetClient`, `CommandClient`, `PackageClient`, `TransactionClient`, `VersionClient` now exists a variant which doesn't depend on a ledger id at initialization and instead requires one for every function as parameter. Moreover the existing classes are extending these classes with overriding the methods and setting the default of the parameter with the given ledger id from initialization. The class `LedgerClientWithoutLedgerId` already makes usage of these variants e.g. `PackageClientWithoutLedgerId`. - [Ledger Client Scala Bindings] The function `transactionSource` of the class `LedgerClientBinding` now optionally accepts a token which is passed on to the unterlying call. - [JSON API] The Oracle database schema has changed; if using ``--query-store-jdbc-config``, you must rebuild the database by adding ``,start-mode=create-only``. See #10539. - [Trigger Service] ``--help`` no longer advertises unsupported JDBC options from JSON API. - [JSON API] [EE only] By default, on Oracle, sets up a JSON search index to speed up the queries endpoints. However, Oracle versions prior to 19.12 have an unrecoverably buggy implementation of this index; in addition, the current implementation fails on queries with strings >256 bytes, with no way to disable the index for that query. Pass the ``disableContractPayloadIndexing=true`` option as part of ``--query-store-jdbc-config`` to disable this index when creating the schema. See `issue #10539 <https://github.com/digital-asset/daml/pull/10539>`__. - [Integration Kit] Changes the Offset format to contain a version and therefore reduces the highest index size by one byte - [Ledger API Server] The command deduplication time is no longer used for determining the period of time to track the command before giving up. Instead, the gRPC deadline is used. If no deadline is provided (or if the deadline exceeds the command tracker retention period), the tracker retention period is used instead. - [Daml Repl] Fix a bug where bindings with out of scope types would result in error in following lines. - [Sandbox, participant] Added a flag to enable a new append-only database schema. This schema was designed to support significantly higher performance. In a future release, all applications will automatically migrate to the new schema. - [Ledger API Server] The command service now uses the tracker retention period (typically specified with the ``--tracker-retention-period`` command-line argument) as the maximum time to wait for a command to arrive on the completion stream. After this time, the command will time out, though it may still complete in the future. Previously, the deduplication period was used, but it was likely the tracker would be terminated before that anyway. The default tracker retention period is 5 minutes, unless otherwise specified. - [DPP-418] [Participant] Add support for supplying server's private key as an encrypted file and then decrypting it with the help of a secrets server. [Integration Kit] KV-based ledgers pass contract instances through the Write/ReadService, removing the need for backfilling divulged contract lookups. Note: KV Ledgers that have been created before this change will still be relying on backfilling lookups of divulged contracts, hence pruning of all divulged contracts may result in failing lookups for divulged contracts. ledger-api - add `deduplication_duration` as a future replacement for `deduplication_time` in the command proto definition ledger-api - Command deduplication period can now be specified by setting `deduplication_offset` instead of `deduplication_time` (only valid for v2 WriteService). This change is backwards compatible. ``` CHANGELOG_BEGIN CHANGELOG_END
This PR has been created by a script, which is not very smart and does not have all the context. Please do double-check that the version prefix is correct before merging. @aherrmann-da is in charge of this release. Commit log: ``` f058c2f DPP-368 clean up flags (#10711) 90ad24f [Divulgence pruning] Prune immediate divulgence [DPP-513] (#10691) 183934b Command dedup: add columns to completions in append-only schemas [KVL-1057] (#10652) 27c1333 LF: Drop outdated TODOs (#10725) 9be577a Enable pruning in the sandbox-classic when the append-only schema is used [DPP-567] (#10708) 9f072ae Ledger-API Conformance test for Contract ID V0 (#10717) 867547c DPP-368 enable append-only flag in sandbox (#10710) bdc511e [DPP-438] Change open-ended metric names into static ones (by removing partyName part) (#10706) 0c82006 [Divulgence pruning] Prune all divulged contracts only after migration offset [DPP-483] (#10661) 2555dbb Use soft references for values in the caches (#10715) 7fd5906 Add LedgerClientWithoutLedgerId next to the LedgerClient (#10681) 856c69c participant-integration-api: Increase a test timeout. (#10721) b86d07d remove non functioning oracle json array indices (#10720) f5e1756 sandbox-classic: Remove default parameters in `SqlLedger.Owner`. (#10718) 9ef3377 LF: Update specification with Contract ID Comparability check (#10703) e5c4734 enable JSON search index on Oracle by default (#10539) 1ded42f [DPP-418] Protect TLS keys - follow-up cleanup (#10696) 3fcd986 Introduce a new `Offset` format [KVL-1063] (#10668) a5781a6 update NOTICES file (#10714) 8985505 participant-integration-api: Use deadlines, not deduplication times, for expiring trackers. [KVL-1009] (#10704) 65025c2 sandbox-classic: Add ErrorInfo metadata for rejections. [KVL-1048] (#10707) 97bda3c LF: V1 Contract ID check in Preprocessor (#10687) c2f90ef Add CLI option to force disabling of participant deduplication (#10698) 6016633 Construct ParsedModule directly in Daml Repl (#10701) bbdf16a DPP-368 unhide append-only CLI flags (#10697) a41b134 Use the tracker retention period as the maximum expiry time. [KVL-1009] (#10700) e750ba5 Make warning less scary. (#10699) 5f120bd rotate release duty after 1.17.0-snapshot.20210824.7647.0.640fb683 (#10660) a17253f DPP-535 Verify postgres version (#10577) 301ce53 participant-integration-api: Add tests for ApiCommandService. [KVL-1009] (#10689) bd01a21 [DPP-418] Protect Participant TLS keys (#10629) 7ee1324 update NOTICES file (#10695) 7c392f3 update NOTICES file (#10693) 3db654e update NOTICES file (#10690) eff09c0 ledger-api-client: Wrap command submissions in a new class. [KVL-1009] (#10683) d54adb2 Ledger-API: Conformance tests for contract IDs suffixing (#10654) aa2e869 [Divulgence pruning] Pass divulged contract arguments through kvutils Write/ReadService [DPP-535] (#10598) 1a78313 Disable DeeplyNestedValueIT suite against canton in Daml repo (#10686) b5f9be3 participant-integration-api: Standardize tracker retention naming. (#10682) 2aa632e ledger-on-sql: Do not increment the dispatcher head on start. (#10684) eabb19d [ledger-api] Add deduplication_duration to deduplication period [kvl-1047] (#10676) 96ad9b5 [Divulgence pruning] All divulgence events pruning [DPP-483] (#10634) 0b7980d Update rules_haskell (#10674) 284edfc Fix FlywayMigrations datasource (#10666) adbe65f Document ActionFail vs CanAbort (#10657) 52e7a6d update compat versions for 1.17.0-snapshot.20210824.7647.0.640fb683 (#10667) f42e6b6 Expose pending contracts in triggers (#10672) 7cc6989 Add multiple ways of specifying deduplication [KVL-1047] (#10601) 53be19f participant-integration-api: Ensure that all waiting, failed, and closed trackers are cleaned up. (#10662) b27cde6 participant-integration-api: Move tracker code around, and tidy up tests. (#10663) fc9d359 Drop alternative rules from dlint config (#10646) 5204d3c Include committers in PartialTransaction root context (#10665) 387c68b Normalize transaction values within the engine (#10648) 430c1cc release 1.17.0-snapshot.20210824.7647.0.640fb683 (#10659) ef239fd participant-integration-api: Move `TrackerMap` code around. [KVL-1009] (#10653) ``` Changelog: ``` - [Sandbox] - Participant pruning is enabled in the sandbox-classic when the append-only schema is used - [Ledger Client Scala Bindings] A new variant of the LedgerClient class was added called `LedgerClientWithoutLedgerId`. This class does not need a ledger id at initialization. It was added to allow skipping any checks at initialization for use cases where either the ledger id is not known at initalization or no valid token can be fed at initialization for checking the ledger id. Furthermore for each classes `ActiveContractSetClient`, `CommandClient`, `PackageClient`, `TransactionClient`, `VersionClient` now exists a variant which doesn't depend on a ledger id at initialization and instead requires one for every function as parameter. Moreover the existing classes are extending these classes with overriding the methods and setting the default of the parameter with the given ledger id from initialization. The class `LedgerClientWithoutLedgerId` already makes usage of these variants e.g. `PackageClientWithoutLedgerId`. - [Ledger Client Scala Bindings] The function `transactionSource` of the class `LedgerClientBinding` now optionally accepts a token which is passed on to the unterlying call. - [JSON API] The Oracle database schema has changed; if using ``--query-store-jdbc-config``, you must rebuild the database by adding ``,start-mode=create-only``. See #10539. - [Trigger Service] ``--help`` no longer advertises unsupported JDBC options from JSON API. - [JSON API] [EE only] By default, on Oracle, sets up a JSON search index to speed up the queries endpoints. However, Oracle versions prior to 19.12 have an unrecoverably buggy implementation of this index; in addition, the current implementation fails on queries with strings >256 bytes, with no way to disable the index for that query. Pass the ``disableContractPayloadIndexing=true`` option as part of ``--query-store-jdbc-config`` to disable this index when creating the schema. See `issue #10539 <https://github.com/digital-asset/daml/pull/10539>`__. - [Integration Kit] Changes the Offset format to contain a version and therefore reduces the highest index size by one byte - [Ledger API Server] The command deduplication time is no longer used for determining the period of time to track the command before giving up. Instead, the gRPC deadline is used. If no deadline is provided (or if the deadline exceeds the command tracker retention period), the tracker retention period is used instead. - [Daml Repl] Fix a bug where bindings with out of scope types would result in error in following lines. - [Sandbox, participant] Added a flag to enable a new append-only database schema. This schema was designed to support significantly higher performance. In a future release, all applications will automatically migrate to the new schema. - [Ledger API Server] The command service now uses the tracker retention period (typically specified with the ``--tracker-retention-period`` command-line argument) as the maximum time to wait for a command to arrive on the completion stream. After this time, the command will time out, though it may still complete in the future. Previously, the deduplication period was used, but it was likely the tracker would be terminated before that anyway. The default tracker retention period is 5 minutes, unless otherwise specified. - [DPP-418] [Participant] Add support for supplying server's private key as an encrypted file and then decrypting it with the help of a secrets server. [Integration Kit] KV-based ledgers pass contract instances through the Write/ReadService, removing the need for backfilling divulged contract lookups. Note: KV Ledgers that have been created before this change will still be relying on backfilling lookups of divulged contracts, hence pruning of all divulged contracts may result in failing lookups for divulged contracts. ledger-api - add `deduplication_duration` as a future replacement for `deduplication_time` in the command proto definition ledger-api - Command deduplication period can now be specified by setting `deduplication_offset` instead of `deduplication_time` (only valid for v2 WriteService). This change is backwards compatible. ``` CHANGELOG_BEGIN CHANGELOG_END Co-authored-by: Azure Pipelines DAML Build <support@digitalasset.com>
Description
This is a further change in a series (after #10619) to let the Ledger API provide more command de-duplication information in completions as well (only the submission rank is deferred to later stages), so that the application can use it in correlation with the one provided at command submission time.
It updates the index DB append-only schema to allow storing the additional command de-duplication information and provides the read/write logic for it.
CHANGELOG_BEGIN
CHANGELOG_END
Pull Request Checklist
CHANGELOG_BEGIN
andCHANGELOG_END
tagsNOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with
/AzurePipelines run
totrigger the build.