-
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
participant-integration-api: Store a status gRPC protobuf. [KVL-1005] #10600
Conversation
It's only used here; there's no reason to keep it in the _participant-integration-api_.
...integration-api/src/main/resources/db/migration/oracle-appendonly/V1__Append_only_schema.sql
Outdated
Show resolved
Hide resolved
// But for an api server that is part of a distributed ledger network, we might see | ||
// transactions that originated from some other api server. These transactions don't contain the submitter information, | ||
// and therefore we don't emit CommandAccepted completions for those | ||
def apply( |
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 function was inlined into InMemoryLedger
in Sandbox Classic, as it's only used there.
...t-integration-api/src/main/resources/db/migration/h2database/V31__rejection_status_proto.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
...gration-api/src/main/resources/db/migration/h2database-appendonly/V1__Append_only_schema.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
...integration-api/src/main/resources/db/migration/oracle-appendonly/V1__Append_only_schema.sql
Outdated
Show resolved
Hide resolved
ledger/participant-integration-api/src/main/resources/db/migration/oracle/V1__Init.sql
Outdated
Show resolved
Hide resolved
.../main/resources/db/migration/postgres-appendonly/V106__add_rejection_status_proto_column.sql
Outdated
Show resolved
Hide resolved
How about the "vintage" one? |
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.
Nice work!
Do we have any sort of integration tests that we can use to validate the behavior when reading completions that we stored both with the old status
and message
along with the new rejection_status
format?
...integration-api/src/main/resources/db/migration/oracle-appendonly/V1__Append_only_schema.sql
Outdated
Show resolved
Hide resolved
.../main/resources/db/migration/postgres-appendonly/V106__add_rejection_status_proto_column.sql
Outdated
Show resolved
Hide resolved
.../participant-integration-api/src/main/scala/platform/store/dao/CommandCompletionsTable.scala
Show resolved
Hide resolved
Instead of storing the status code and message, we store a serialized `google.rpc.Status` protocol buffers message. This allows us to pass through any additional information reported by the driver `ReadService`. The migration is only done for the append-only database, and preserves old data in the existing columns. New data will only be written to the new column. CHANGELOG_BEGIN CHANGELOG_END
f4d6de7
to
1fd2a37
Compare
Co-authored-by: Fabio Tudone <fabio.tudone@digitalasset.com>
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.
nice'n'easy 👍 thanks @SamirTalwar (commented only on minor stuff)
...gration-api/src/main/resources/db/migration/h2database-appendonly/V1__Append_only_schema.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
...integration-api/src/main/resources/db/migration/oracle-appendonly/V1__Append_only_schema.sql
Outdated
Show resolved
Hide resolved
val parserWithCodeAndMessage = sharedColumns ~ | ||
int("rejection_status_code") ~ str("rejection_status_message") map { | ||
case offset ~ recordTime ~ commandId ~ rejectionStatusCode ~ rejectionStatusMessage => | ||
val status = StatusProto.of(rejectionStatusCode, rejectionStatusMessage, Seq.empty) | ||
CompletionFromTransaction.rejectedCompletion(recordTime, offset, commandId, status) | ||
} |
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.
do you think we have tests somewhere to test this part?
normally it would not be tested because on the HEAD we would always populate the rejection_status
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.
@rautenrieth-da did you maybe encountered a test suit which would test this?
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.
We are very bad at testing migrations. I have no idea how we would go about testing this.
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 compatibility package tests migrations in a way. It does:
- install an old SDK version
- push some data into a sandbox ledger, using the ledger API
- upgrade to the next SDK version (up to and including the head version)
- use the ledger API to check that the ledger content still looks the same
- go to step 2
The application that uploads and checks data is a custom client application written in Haskell. There are checks for comparing the ACS and contract visibility due to divulgence. It could probably be extended to compare completions 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.
Yeah but do we also test rejections this way? Never mind me, it will probably work...although we would not necessarily would have here dead code if we follow @miklos-da useful suggestion
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 don't think we test rejections, but we could extend the compatibility tests to cover them.
@SamirTalwar-DA Thinking more about this, I'm not really convinced that we should store the raw |
@nicu-da: This is a reasonable concern. Fortunately, The reason we need to store a protobuf (as opposed to just having columns) is because with the new API, the ledger is capable of passing back arbitrary information as part of the |
f9f27b5
to
c7a74a0
Compare
@SamirTalwar-DA could you elaborate on the reason why we only need to do this for the append-only schema? |
@fabiotudone-da: We have decided that we will only support the v2 participant state API with the append-only index. This means that there will never be any "details" in the We decided this because adding a new migration to the mutable index causes a whole load of problems right now. This is due to the way migrations are ordered within our codebase: all mutable index migrations must be applied before migrating to the append-only index. If we add a new one, it'll break any existing deployments using the append-only index schema. We hope that the mutable index will be phased out fairly shortly, so this strange situation should ideally be temporary. |
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.
LGTM!
Instead of storing the status code and message, we store a serialized `google.rpc.Status` protocol buffers message. This allows us to pass through any additional information reported by the driver `ReadService`. The migration is done in Scala because constructing protobuf messages in SQL turns out to be very, very unpleasant. CHANGELOG_BEGIN CHANGELOG_END
...gration-api/src/main/resources/db/migration/h2database-appendonly/V1__Append_only_schema.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
Serializing the details but keeping the code and message columns populated.
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.
Elegant solution!
…#10600) * participant-integration-api: Construct completions in one place. * sandbox-classic: Inline `CompletionFromTransaction#apply`. It's only used here; there's no reason to keep it in the _participant-integration-api_. * participant-integration-api: Store a status gRPC protobuf. Instead of storing the status code and message, we store a serialized `google.rpc.Status` protocol buffers message. This allows us to pass through any additional information reported by the driver `ReadService`. The migration is only done for the append-only database, and preserves old data in the existing columns. New data will only be written to the new column. CHANGELOG_BEGIN CHANGELOG_END * participant-integration-api: Improve comments in migrations. Co-authored-by: Fabio Tudone <fabio.tudone@digitalasset.com> * participant-integration-api: Further improvements to migrations. * participant-integration-api: Store the rejection status as 3 columns. Serializing the details but keeping the code and message columns populated. * participant-integration-api: Publish the indexer protobuf to Maven. Co-authored-by: Fabio Tudone <fabio.tudone@digitalasset.com>
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. @SamirTalwar-DA is in charge of this release. Commit log: ``` 640fb68 Make Index DB enable multiple party additions [DPP-546] (#10623) b22de68 LF: Contract ID suffix check in Preprocessor (#10642) 7b94b06 Map shortened scala test suite names to long names on Windows (#10628) 6e4a24c participant-state: Generate correct gRPC error codes by v2 `WriteService` [KVL-1081] (#10656) 663781a Update curl 7.73.0 --> 7.78.0 (#10655) a471f15 Dpp-558 Fix startexclusive queries on oracle (#10649) e99254f Augment `completion.proto` with deduplication-related info [KVL-1057] (#10619) a00608c participant-integration-api: Accommodate changes to max dedup time. (#10650) 29c546c [Divulgence pruning] Added `prune_all_divulged_contracts` to PruneRequest [DPP-534] (#10635) dea57ca In-memory fan-out optimizations (#10558) 77eb366 [JSON-API] key_hash field to speed up fetchByKey queries (#10631) 5001329 LF: Comparisons fail at runtime if comparing local vs global CIDs (#10630) 055be4b Disable deprecation warnings for data-dependencies (#10647) c155935 clean-up gsg README (#10641) 8501832 DPP-468 StorageBackend tests (#10529) 4e08b47 update NOTICES file (#10645) 733590d ledger-api-health: Use the Scala health status values everywhere. (#10640) 5b837ec Ledger API: add `buf` checks [KVL-1045] (#10625) f77cd0a participant-integration-api: Attempt to fix RecoveringIndexerSpec. (#10639) 9d7f60f participant-integration-api: Fix a flaky test. (#10637) 4a9331c Upgrade Nixpkgs [KVL-1045] (#10624) 01b6e89 update compat versions for 1.17.0-snapshot.20210817.7604.0.0c187853 (#10610) b578b0e Reminder to put an empty line between subject and body (#10638) c0fbad1 participant-integration-api: Remove `limitMaxCommandsInFlight`. (#10626) b4af6d1 Canton testing: Mark one more DeeplyNestedValueIT test flaky (#10636) e807f4a Upgrade to a newer canton version (post 0.27.0 snapshot version) (#10632) c4513f2 Oracle append-only schema: enable contract id index on participant_events_xxxx tables (#10633) 3598e09 LF: Drop contract ID Freshness check (#10620) 37c999e ledger-on-sql: Increase the concurrency for conformance tests. (#10622) 46e8c7d DPP-460 Extract constant for event sequential IDs (#10564) 121047e DPP-460 Parameter storage consolidation (#10472) 569612a Drop broken symlink config (#10616) 6d0109f Support $ in daml-lf identifiers in the parser (#10609) c38703e participant-integration-api: Store a status gRPC protobuf. [KVL-1005] (#10600) 0af5b49 make FinalReason a case class (#10614) 8dd136f bazel-tools: Replace `runner` with either `runner_with_port_check` or `runner_with_port_file`. (#10615) 19c3d28 Remove GenMissingString class because it is not used (#10608) 3227e86 Use the port file and dynamic port generation in client/server tests. (#10604) fb19bcb fix gsg-trigger template (#10611) b207702 rotate release duty after 1.17.0-snapshot.20210817.7604.0.0c187853 (#10606) 975a5fb Move DeduplicationPeriod to ledger-api-domain [KVL-1047] (#10590) f8a1820 release 1.17.0-snapshot.20210817.7604.0.0c187853 (#10605) 64abf8a update NOTICES file (#10607) ``` Changelog: ``` [Integration Kit] Corrected gRPC error codes returned by v2 `WriteService` adaptor. - [Ledger API Server] The API server manages a single command tracker per (application ID × submitters) pair. This tracker would read the current ledger configuration's maximum deduplication time on creation, but never updated it, leading to trackers that might inadvertently reject a submission when it should have been accepted. The tracker now reads the latest ledger configuration. - Update schema version for http-json-api query store with new key_hash field - Improved performance for fetchByKey query which now uses key_hash field participant-state - move `DeduplicationPeriod` to ledger-api-domain dc4629f update NOTICES file (#10580) 8b0a0e7 update NOTICES file (#10578) 4b8b67a Upgrade Scalatest to v3.2.9. (#10576) 41e60f7 Upgrade to Scala 2.12.14 and 2.13.6. (#10573) c447898 Fix display of unhandled exceptions in the scenario service (#10572) 4e1a90d Enable --incompatible_remote_results_ignore_disk (#10571) d183ecc rotate release duty after 1.17.0-snapshot.20210811.7560.0.4f9de4ba (#10556) 76ecb44 update compat versions for 1.17.0-snapshot.20210811.7565.0.f1a55aa4 (#10563) 86a03fa Bump bazel max jvm memory (#10569) 1cc136c update NOTICES file (#10565) c69880c ledger-api-test-tool: Enforce test naming standards. (#10562) ee34d0f Track command - use types for error handling instead of grpc statuses [KVL-1005] (#10503) 93c25f3 Release 1.17 snapshot (#10560) ``` Changelog: ``` - [Ledger API Test Tool] The ``TransactionServiceIT`` test suite has been split into many test suites. If you are including or excluding it, you will need to use the new test suite names, or you can use "TransactionService" as a prefix for all of them. If you are including or excluding individual tests, you will need to update your arguments with the new test suite. You can find the new test suite by running the test tool with the ``--list-all`` flag and looking for the test's short identifier. The short identifiers have not changed, with the exception of ``TXNoContractKey``, which has been renamed to ``CKNoContractKey`` and is now in the ``ContractKeysIT`` test suite. * [Daml export] You can now set the ``--all-parties`` option to generate a ledger export as seen by all known parties. ledger-api-client - Propagate definite_answer as metadata in the GRPC response for submit/submitAndWait [JSON API] Ledger connection errors are now logged at every attempt akka-bindings: `LedgerClientBinding.commands` now returns a flow of `Either[CompletionFailure, CompletionSuccess]` instead of `Completion` for clearer error handling. For backwards compatiblity the new return type can be turned back into a `Completion` using `CompletionResponse.toCompletion` ``` ``` 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. @SamirTalwar-DA is in charge of this release. Commit log: ``` 640fb68 Make Index DB enable multiple party additions [DPP-546] (#10623) b22de68 LF: Contract ID suffix check in Preprocessor (#10642) 7b94b06 Map shortened scala test suite names to long names on Windows (#10628) 6e4a24c participant-state: Generate correct gRPC error codes by v2 `WriteService` [KVL-1081] (#10656) 663781a Update curl 7.73.0 --> 7.78.0 (#10655) a471f15 Dpp-558 Fix startexclusive queries on oracle (#10649) e99254f Augment `completion.proto` with deduplication-related info [KVL-1057] (#10619) a00608c participant-integration-api: Accommodate changes to max dedup time. (#10650) 29c546c [Divulgence pruning] Added `prune_all_divulged_contracts` to PruneRequest [DPP-534] (#10635) dea57ca In-memory fan-out optimizations (#10558) 77eb366 [JSON-API] key_hash field to speed up fetchByKey queries (#10631) 5001329 LF: Comparisons fail at runtime if comparing local vs global CIDs (#10630) 055be4b Disable deprecation warnings for data-dependencies (#10647) c155935 clean-up gsg README (#10641) 8501832 DPP-468 StorageBackend tests (#10529) 4e08b47 update NOTICES file (#10645) 733590d ledger-api-health: Use the Scala health status values everywhere. (#10640) 5b837ec Ledger API: add `buf` checks [KVL-1045] (#10625) f77cd0a participant-integration-api: Attempt to fix RecoveringIndexerSpec. (#10639) 9d7f60f participant-integration-api: Fix a flaky test. (#10637) 4a9331c Upgrade Nixpkgs [KVL-1045] (#10624) 01b6e89 update compat versions for 1.17.0-snapshot.20210817.7604.0.0c187853 (#10610) b578b0e Reminder to put an empty line between subject and body (#10638) c0fbad1 participant-integration-api: Remove `limitMaxCommandsInFlight`. (#10626) b4af6d1 Canton testing: Mark one more DeeplyNestedValueIT test flaky (#10636) e807f4a Upgrade to a newer canton version (post 0.27.0 snapshot version) (#10632) c4513f2 Oracle append-only schema: enable contract id index on participant_events_xxxx tables (#10633) 3598e09 LF: Drop contract ID Freshness check (#10620) 37c999e ledger-on-sql: Increase the concurrency for conformance tests. (#10622) 46e8c7d DPP-460 Extract constant for event sequential IDs (#10564) 121047e DPP-460 Parameter storage consolidation (#10472) 569612a Drop broken symlink config (#10616) 6d0109f Support $ in daml-lf identifiers in the parser (#10609) c38703e participant-integration-api: Store a status gRPC protobuf. [KVL-1005] (#10600) 0af5b49 make FinalReason a case class (#10614) 8dd136f bazel-tools: Replace `runner` with either `runner_with_port_check` or `runner_with_port_file`. (#10615) 19c3d28 Remove GenMissingString class because it is not used (#10608) 3227e86 Use the port file and dynamic port generation in client/server tests. (#10604) fb19bcb fix gsg-trigger template (#10611) b207702 rotate release duty after 1.17.0-snapshot.20210817.7604.0.0c187853 (#10606) 975a5fb Move DeduplicationPeriod to ledger-api-domain [KVL-1047] (#10590) f8a1820 release 1.17.0-snapshot.20210817.7604.0.0c187853 (#10605) 64abf8a update NOTICES file (#10607) ``` Changelog: ``` [Integration Kit] Corrected gRPC error codes returned by v2 `WriteService` adaptor. - [Ledger API Server] The API server manages a single command tracker per (application ID × submitters) pair. This tracker would read the current ledger configuration's maximum deduplication time on creation, but never updated it, leading to trackers that might inadvertently reject a submission when it should have been accepted. The tracker now reads the latest ledger configuration. - Update schema version for http-json-api query store with new key_hash field - Improved performance for fetchByKey query which now uses key_hash field participant-state - move `DeduplicationPeriod` to ledger-api-domain dc4629f update NOTICES file (#10580) 8b0a0e7 update NOTICES file (#10578) 4b8b67a Upgrade Scalatest to v3.2.9. (#10576) 41e60f7 Upgrade to Scala 2.12.14 and 2.13.6. (#10573) c447898 Fix display of unhandled exceptions in the scenario service (#10572) 4e1a90d Enable --incompatible_remote_results_ignore_disk (#10571) d183ecc rotate release duty after 1.17.0-snapshot.20210811.7560.0.4f9de4ba (#10556) 76ecb44 update compat versions for 1.17.0-snapshot.20210811.7565.0.f1a55aa4 (#10563) 86a03fa Bump bazel max jvm memory (#10569) 1cc136c update NOTICES file (#10565) c69880c ledger-api-test-tool: Enforce test naming standards. (#10562) ee34d0f Track command - use types for error handling instead of grpc statuses [KVL-1005] (#10503) 93c25f3 Release 1.17 snapshot (#10560) ``` Changelog: ``` - [Ledger API Test Tool] The ``TransactionServiceIT`` test suite has been split into many test suites. If you are including or excluding it, you will need to use the new test suite names, or you can use "TransactionService" as a prefix for all of them. If you are including or excluding individual tests, you will need to update your arguments with the new test suite. You can find the new test suite by running the test tool with the ``--list-all`` flag and looking for the test's short identifier. The short identifiers have not changed, with the exception of ``TXNoContractKey``, which has been renamed to ``CKNoContractKey`` and is now in the ``ContractKeysIT`` test suite. * [Daml export] You can now set the ``--all-parties`` option to generate a ledger export as seen by all known parties. ledger-api-client - Propagate definite_answer as metadata in the GRPC response for submit/submitAndWait [JSON API] Ledger connection errors are now logged at every attempt akka-bindings: `LedgerClientBinding.commands` now returns a flow of `Either[CompletionFailure, CompletionSuccess]` instead of `Completion` for clearer error handling. For backwards compatiblity the new return type can be turned back into a `Completion` using `CompletionResponse.toCompletion` ``` ``` CHANGELOG_BEGIN CHANGELOG_END Co-authored-by: Azure Pipelines DAML Build <support@digitalasset.com>
Instead of storing the status code and message, we store a serialized
google.rpc.Status
protocol buffers message. This allows us to pass through any additional information reported by the driverReadService
.The migration is only done for the append-only index, and preserves old data in the existing columns. New data will only be written to the new column. We'll make sure this is OK by only supporting the append-only index with the v2
ReadService
.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.