-
Notifications
You must be signed in to change notification settings - Fork 114
Test handling of multiple verdicts with the same update_id #7007
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
Open
mrdziuban
wants to merge
7
commits into
canton-network:main
Choose a base branch
from
obsidiansystems:mrdziuban/dupe-verdict-update-id/6192
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
631fe63
Log a warning when dropped duplicate verdicts include an accept.
mrdziuban 9623202
Add tests to cover duplicate verdict handling.
mrdziuban 19b6187
Document deduplication of verdicts by update_id.
mrdziuban 7b0f286
Identify and log duplicte verdicts within a batch.
mrdziuban a527859
Describe reject after accept scenario in documentation.
mrdziuban 725867f
Only log a warning if a duplicate accept appears after another verdict.
mrdziuban 6062e19
Update `ScanEventStoreTest` to assert against the warning log.
mrdziuban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -412,6 +412,101 @@ class DbAppActivityRecordStoreTest | |
| countAfter shouldBe 0L | ||
| } | ||
| } | ||
|
|
||
| "drop a rejected verdict that's a duplicate of a prior accept" in { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we already have the behavior that reject-after-accept does not warn. |
||
| val updateId = "update-dupe-reject-after-accept" | ||
| val ts1 = CantonTimestamp.now() | ||
| val ts2 = ts1.plusSeconds(1L) | ||
| for { | ||
| (appStore, verdictStore) <- newStores() | ||
| accepted = mkVerdict( | ||
| verdictStore, | ||
| updateId, | ||
| ts1, | ||
| DbScanVerdictStore.VerdictResultDbValue.Accepted, | ||
| ) | ||
| rejected = mkVerdict( | ||
| verdictStore, | ||
| updateId, | ||
| ts2, | ||
| DbScanVerdictStore.VerdictResultDbValue.Rejected, | ||
| ) | ||
| // First batch with the accepted verdict and its activity record | ||
| _ <- verdictStore.insertVerdictsWithAppActivityRecords( | ||
| NonEmptyList.of(accepted -> noViews), | ||
| Seq(ts1 -> mkRecord(0L, 10L, Seq("app1::provider"), Seq(100L))), | ||
| hasTrafficSummaries = true, | ||
| firstActiveRoundO = Some(10L), | ||
| lastArchivedRoundO = Some(9L), | ||
| ) | ||
| countAfterBatch1 <- countRecords() | ||
| // A later batch with a rejection for the same update_id | ||
| _ <- verdictStore.insertVerdictsWithAppActivityRecords( | ||
| NonEmptyList.of(rejected -> noViews), | ||
| Seq(ts2 -> mkRecord(0L, 11L, Seq("app2::provider"), Seq(200L))), | ||
| hasTrafficSummaries = true, | ||
| firstActiveRoundO = Some(11L), | ||
| lastArchivedRoundO = Some(10L), | ||
| ) | ||
| v <- verdictStore.getVerdictByUpdateId(updateId) | ||
| countAfterBatch2 <- countRecords() | ||
| } yield { | ||
| v shouldBe defined | ||
| v.value.verdictResult shouldBe DbScanVerdictStore.VerdictResultDbValue.Accepted | ||
| v.value.recordTime shouldBe ts1 | ||
| // The rejection's activity record was dropped along with the verdict | ||
| countAfterBatch2 shouldBe countAfterBatch1 | ||
| } | ||
| } | ||
|
|
||
| "drop and warn of an accepted verdict that's a duplicate of a prior rejection" in { | ||
| val updateId = "update-dupe-accept-after-reject" | ||
| val ts1 = CantonTimestamp.now() | ||
| val ts2 = ts1.plusSeconds(1L) | ||
| for { | ||
| (appStore, verdictStore) <- newStores() | ||
| rejected = mkVerdict( | ||
| verdictStore, | ||
| updateId, | ||
| ts1, | ||
| DbScanVerdictStore.VerdictResultDbValue.Rejected, | ||
| ) | ||
| accepted = mkVerdict( | ||
| verdictStore, | ||
| updateId, | ||
| ts2, | ||
| DbScanVerdictStore.VerdictResultDbValue.Accepted, | ||
| ) | ||
| // First batch with the rejection and its activity record | ||
| _ <- verdictStore.insertVerdictsWithAppActivityRecords( | ||
| NonEmptyList.of(rejected -> noViews), | ||
| Seq(ts1 -> mkRecord(0L, 10L, Seq("app1::provider"), Seq(100L))), | ||
| hasTrafficSummaries = true, | ||
| firstActiveRoundO = Some(10L), | ||
| lastArchivedRoundO = Some(9L), | ||
| ) | ||
| countAfterBatch1 <- countRecords() | ||
| // A later batch with an accept for the same update_id | ||
| _ <- loggerFactory.assertLogs( | ||
| verdictStore.insertVerdictsWithAppActivityRecords( | ||
| NonEmptyList.of(accepted -> noViews), | ||
| Seq(ts2 -> mkRecord(0L, 11L, Seq("app2::provider"), Seq(200L))), | ||
| hasTrafficSummaries = true, | ||
| firstActiveRoundO = Some(11L), | ||
| lastArchivedRoundO = Some(10L), | ||
| ), | ||
| _.warningMessage should startWith("Dropping duplicate accepted verdicts"), | ||
| ) | ||
| v <- verdictStore.getVerdictByUpdateId(updateId) | ||
| countAfterBatch2 <- countRecords() | ||
| } yield { | ||
| v shouldBe defined | ||
| v.value.verdictResult shouldBe DbScanVerdictStore.VerdictResultDbValue.Rejected | ||
| v.value.recordTime shouldBe ts1 | ||
| // The accept's activity record was dropped along with the verdict | ||
| countAfterBatch2 shouldBe countAfterBatch1 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| "earliestRoundWithCompleteAppActivity" should { | ||
|
|
@@ -1202,6 +1297,7 @@ class DbAppActivityRecordStoreTest | |
| verdictStore: DbScanVerdictStore, | ||
| updateId: String, | ||
| recordTs: CantonTimestamp, | ||
| verdictResult: Short = DbScanVerdictStore.VerdictResultDbValue.Accepted, | ||
| ): verdictStore.VerdictT = | ||
| new verdictStore.VerdictT( | ||
| rowId = 0L, | ||
|
|
@@ -1210,7 +1306,7 @@ class DbAppActivityRecordStoreTest | |
| recordTime = recordTs, | ||
| finalizationTime = recordTs, | ||
| submittingParticipantUid = "participant1", | ||
| verdictResult = DbScanVerdictStore.VerdictResultDbValue.Accepted, | ||
| verdictResult = verdictResult, | ||
| mediatorGroup = 0, | ||
| updateId = updateId, | ||
| submittingParties = Seq.empty, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As noted above, this particular order should not warn.