Skip to content
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

fix(datastore): wrap failures to result when applying remote update events #3187

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

5d
Copy link
Member

@5d 5d commented Aug 28, 2023

Issue #

#1903

Description

We apply remote update events in batch. The existing code converts all the update operations into Future<Void, DataStoreError>, and merge them into one stream. The problem arises when a Future completes with an error; it causes the entire stream to terminate as an error. This behavior is unintentional and results in some update operations being silently discarded.

The solution here is simply change Future<Void, DataStoreError> to Future<Result<Void, DataStoreError>, Never>, which wraps the failure to a result type and makes the operation stream never fail.

General Checklist

  • Added new tests to cover change, if needed
  • Build succeeds with all target using Swift Package Manager
  • All unit tests pass
  • All integration tests pass
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)
  • Documentation update for the change if required
  • PR title conforms to conventional commit style
  • New or updated tests include Given When Then inline code documentation and are named accordingly testThing_condition_expectation()
  • If breaking change, documentation/changelog update with migration instructions

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@5d 5d marked this pull request as ready for review August 28, 2023 18:47
@5d 5d requested a review from a team as a code owner August 28, 2023 18:47
@codecov-commenter
Copy link

Codecov Report

Merging #3187 (e6f054d) into main (82098d1) will decrease coverage by 15.87%.
Report is 3 commits behind head on main.
The diff coverage is 94.44%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@             Coverage Diff             @@
##             main    #3187       +/-   ##
===========================================
- Coverage   80.06%   64.20%   -15.87%     
===========================================
  Files          99     1068      +969     
  Lines        6487    36132    +29645     
===========================================
+ Hits         5194    23198    +18004     
- Misses       1293    12934    +11641     
Flag Coverage Δ
API_plugin_unit_test 66.81% <ø> (?)
AWSPluginsCore 69.55% <ø> (?)
Amplify 48.01% <ø> (?)
Analytics_plugin_unit_test 86.39% <ø> (?)
Auth_plugin_unit_test 74.59% <ø> (?)
CoreMLPredictions_plugin_unit_test 59.44% <ø> (?)
DataStore_plugin_unit_test 80.12% <94.44%> (+0.05%) ⬆️
Geo_plugin_unit_test 53.93% <ø> (?)
Logging_plugin_unit_test 62.57% <ø> (?)
Predictions_plugin_unit_test 35.17% <ø> (?)
PushNotifications_plugin_unit_test 69.43% <ø> (?)
Storage_plugin_unit_test 54.10% <ø> (?)
unit_tests 64.20% <94.44%> (-15.87%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...eAndLocalSave/ReconcileAndLocalSaveOperation.swift 90.42% <94.44%> (+1.46%) ⬆️

... and 970 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@5d 5d temporarily deployed to Fortify August 28, 2023 19:41 — with GitHub Actions Inactive
Copy link
Contributor

@lawmicha lawmicha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM. Can we link to some passing integration tests workflows against this change?

@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:02 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:02 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d had a problem deploying to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Failure
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d had a problem deploying to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Failure
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d had a problem deploying to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Failure
@5d 5d had a problem deploying to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Failure
@5d 5d had a problem deploying to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Failure
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d had a problem deploying to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Failure
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:03 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 29, 2023 23:48 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 14:54 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 14:54 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 14:54 — with GitHub Actions Inactive
@5d
Copy link
Member Author

5d commented Sep 1, 2023

9b17942 Deployed 2 days ago by 5d via datastore-lazy-load-test / datastore-integration-lazy-load-test-watchOS #494

I see only two failures in one test suite

Failing tests: DataStoreConnectionScenario1Tests.testDeleteAndGetProjectReturnsNilWithSync() DataStoreConnectionScenario1Tests.testListProjectsByTeamID()

Clicked on re-run

Yeah, our datastore integration test failed randomly. It rarely succeed. https://github.com/aws-amplify/amplify-swift/actions/workflows/integ_test_datastore.yml

@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:17 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:18 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:18 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:18 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest September 1, 2023 16:18 — with GitHub Actions Inactive
@5d 5d merged commit 659fdf9 into main Sep 6, 2023
21 of 22 checks passed
@5d 5d deleted the 5d/issue-1903 branch September 6, 2023 17:05
phantumcode added a commit that referenced this pull request Sep 11, 2023
* main:
  fix(logging): fix issue with logger namespace not being set (#3213)
  fix(datastore): wrap failures to result when applying remote update events (#3187)
  test(storage): update storage integration test with longer expiration duration (#3208)
  chore: finalize release 2.17.1 [skip ci]
  chore: release 2.17.1 [skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants