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

Do transactions correctly #285

Merged
merged 3 commits into from
Mar 14, 2023
Merged

Do transactions correctly #285

merged 3 commits into from
Mar 14, 2023

Conversation

sandreae
Copy link
Member

@sandreae sandreae commented Mar 1, 2023

closes: #283

📋 Checklist

  • Add tests that cover your changes
  • Add this PR to the Unreleased section in CHANGELOG.md
  • Link this PR to any issues it closes
  • New files contain a SPDX license header

@sandreae
Copy link
Member Author

sandreae commented Mar 1, 2023

I saw this test fail again in the CI (only for postgres):

materializer::service::tests::materialize_document_from_bus' panicked at 'called Option::unwrap() on a None value', aquadoggo/src/materializer/[service.rs:237](http://service.rs:237/):38

So it seems this PR does not actually fix that.... However it's still the correct way to use transactions in sqlx.

@codecov
Copy link

codecov bot commented Mar 1, 2023

Codecov Report

Patch coverage: 92.85% and project coverage change: +0.01 🎉

Comparison is base (7b0b8e3) 93.35% compared to head (4317d82) 93.37%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #285      +/-   ##
==========================================
+ Coverage   93.35%   93.37%   +0.01%     
==========================================
  Files          63       63              
  Lines        5180     5179       -1     
==========================================
  Hits         4836     4836              
+ Misses        344      343       -1     
Impacted Files Coverage Δ
aquadoggo/src/db/stores/document.rs 91.63% <92.00%> (+0.18%) ⬆️
aquadoggo/src/db/stores/operation.rs 85.41% <94.11%> (-0.02%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sandreae
Copy link
Member Author

sandreae commented Mar 1, 2023

Hmm, the postgres tests are failing painfully....

test validation::tests::verifies_log_id::case_6_new_public_key_not_next_log_id - should panic ... ok
test validation::tests::verifies_log_id::case_7_new_document_occupied_log_id - should panic ... ok
test validation::tests::verifies_log_id::case_8_new_document_not_next_log_id - should panic ... ok
test validation::tests::verifies_seq_num::case_1_valid_seq_num ... ok
test validation::tests::verifies_seq_num::case_2_seq_num_already_used - should panic ... ok
test validation::tests::verifies_seq_num::case_3_seq_num_too_high - should panic ... ok
test validation::tests::verifies_seq_num::case_4_seq_num_too_high - should panic ... ok
test validation::tests::verifies_seq_num::case_5_no_seq_num - should panic ... ok
failures:
---- materializer::service::tests::materialize_complex_documents stdout ----
-------------- TEST START --------------
thread 'materializer::service::tests::materialize_complex_documents' panicked at 'We expect that the document is `Some`', aquadoggo/src/materializer/service.rs:483:18
---- materializer::service::tests::materialize_document_from_bus stdout ----
-------------- TEST START --------------
thread 'materializer::service::tests::materialize_document_from_bus' panicked at 'We expect that the document is `Some`', aquadoggo/src/materializer/service.rs:234:18
thread 'materializer::service::tests::materialize_document_from_bus' panicked at 'Failed removing completed task from database: Transaction("attempted to acquire a connection on a closed pool")', aquadoggo/src/materializer/service.rs:64:26
---- materializer::service::tests::materialize_update_document stdout ----
-------------- TEST START --------------
thread 'materializer::service::tests::materialize_update_document' panicked at 'assertion failed: `(left == right)`
  left: `String("panda")`,
 right: `String("panda123")`', aquadoggo/src/materializer/service.rs:409:13
failures:
    materializer::service::tests::materialize_complex_documents
    materializer::service::tests::materialize_document_from_bus
    materializer::service::tests::materialize_update_document
test result: FAILED. 238 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 195.40s
error: test failed, to rerun pass `--lib`
Error: The process '/home/runner/.cargo/bin/cargo' failed with exit code 101
test tests::e2e ... ok
test validation::tests::get_expected_skiplink_errors::case_1_expected_skiplink_is_in_store_and_is_same_as_backlink ... ok
test validation::tests::get_expected_skiplink_errors::case_2_skiplink_not_in_store - should panic ... ok
test validation::tests::get_expected_skiplink_errors::case_3_public_key_does_not_exist - should panic ... ok
test validation::tests::get_expected_skiplink_errors::case_4_log_id_is_wrong - should panic ... ok
test validation::tests::get_expected_skiplink_errors::case_5_seq_num_is_one - should panic ... ok
test validation::tests::gets_expected_skiplink::case_01 - should panic ... ok
test validation::tests::gets_expected_skiplink::case_02 ... ok
test validation::tests::gets_expected_skiplink::case_03 ... ok
test validation::tests::gets_expected_skiplink::case_04 ... ok
test validation::tests::gets_expected_skiplink::case_05 ... ok
test validation::tests::gets_expected_skiplink::case_06 ... ok
test validation::tests::gets_expected_skiplink::case_07 ... ok
test validation::tests::gets_expected_skiplink::case_08 ... ok
test validation::tests::gets_expected_skiplink::case_09 ... ok
test validation::tests::gets_expected_skiplink::case_10 ... ok
test validation::tests::identifies_deleted_document - should panic ... ok
test validation::tests::identifies_not_deleted_document ... ok
test validation::tests::increments_log_id::case_1 ... ok
test validation::tests::increments_log_id::case_2 - should panic ... ok
test validation::tests::increments_seq_num::case_1 ... ok
test validation::tests::increments_seq_num::case_2 - should panic ... ok
test validation::tests::verifies_log_id::case_1_existing_document ... ok
test validation::tests::verifies_log_id::case_2_new_document ... ok
test validation::tests::verifies_log_id::case_3_existing_document_new_public_key ... ok
test validation::tests::verifies_log_id::case_4_already_occupied_log_id_for_existing_document - should panic ... ok
test validation::tests::verifies_log_id::case_5_new_log_id_for_existing_document - should panic ... ok
test validation::tests::verifies_log_id::case_6_new_public_key_not_next_log_id - should panic ... ok
test validation::tests::verifies_log_id::case_7_new_document_occupied_log_id - should panic ... ok
test validation::tests::verifies_log_id::case_8_new_document_not_next_log_id - should panic ... ok
test validation::tests::verifies_seq_num::case_1_valid_seq_num ... ok
test validation::tests::verifies_seq_num::case_2_seq_num_already_used - should panic ... ok
test validation::tests::verifies_seq_num::case_3_seq_num_too_high - should panic ... ok
test validation::tests::verifies_seq_num::case_4_seq_num_too_high - should panic ... ok
test validation::tests::verifies_seq_num::case_5_no_seq_num - should panic ... ok
failures:
---- materializer::service::tests::materialize_complex_documents stdout ----
-------------- TEST START --------------
thread 'materializer::service::tests::materialize_complex_documents' panicked at 'We expect that the document is `Some`', aquadoggo/src/materializer/service.rs:483:18
---- materializer::service::tests::materialize_document_from_bus stdout ----
-------------- TEST START --------------
thread 'materializer::service::tests::materialize_document_from_bus' panicked at 'We expect that the document is `Some`', aquadoggo/src/materializer/service.rs:[234](https://github.com/p2panda/aquadoggo/actions/runs/4304615038/jobs/7505892372#step:6:234):18
thread 'materializer::service::tests::materialize_document_from_bus' panicked at 'Failed removing completed task from database: Transaction("attempted to acquire a connection on a closed pool")', aquadoggo/src/materializer/service.rs:64:26
---- materializer::service::tests::materialize_update_document stdout ----
-------------- TEST START --------------
thread 'materializer::service::tests::materialize_update_document' panicked at 'assertion failed: `(left == right)`
  left: `String("panda")`,
 right: `String("panda123")`', aquadoggo/src/materializer/service.rs:409:13
failures:
    materializer::service::tests::materialize_complex_documents
    materializer::service::tests::materialize_document_from_bus
    materializer::service::tests::materialize_update_document
test result: FAILED. 238 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 195.40s
error: test failed, to rerun pass `--lib`
Error: The process '/home/runner/.cargo/bin/cargo' failed with exit code 101
test tests::e2e ... ok
test validation::tests::get_expected_skiplink_errors::case_1_expected_skiplink_is_in_store_and_is_same_as_backlink ... ok
test validation::tests::get_expected_skiplink_errors::case_2_skiplink_not_in_store - should panic ... ok
test validation::tests::get_expected_skiplink_errors::case_3_public_key_does_not_exist - should panic ... ok
test validation::tests::get_expected_skiplink_errors::case_4_log_id_is_wrong - should panic ... ok
test validation::tests::get_expected_skiplink_errors::case_5_seq_num_is_one - should panic ... ok
test validation::tests::gets_expected_skiplink::case_01 - should panic ... ok
test validation::tests::gets_expected_skiplink::case_02 ... ok
test validation::tests::gets_expected_skiplink::case_03 ... ok
test validation::tests::gets_expected_skiplink::case_04 ... ok
test validation::tests::gets_expected_skiplink::case_05 ... ok
test validation::tests::gets_expected_skiplink::case_06 ... ok
test validation::tests::gets_expected_skiplink::case_07 ... ok
test validation::tests::gets_expected_skiplink::case_08 ... ok
test validation::tests::gets_expected_skiplink::case_09 ... ok
test validation::tests::gets_expected_skiplink::case_10 ... ok
test validation::tests::identifies_deleted_document - should panic ... ok
test validation::tests::identifies_not_deleted_document ... ok
test validation::tests::increments_log_id::case_1 ... ok
test validation::tests::increments_log_id::case_2 - should panic ... ok
test validation::tests::increments_seq_num::case_1 ... ok
test validation::tests::increments_seq_num::case_2 - should panic ... ok
test validation::tests::verifies_log_id::case_1_existing_document ... ok
test validation::tests::verifies_log_id::case_2_new_document ... ok
test validation::tests::verifies_log_id::case_3_existing_document_new_public_key ... ok
test validation::tests::verifies_log_id::case_4_already_occupied_log_id_for_existing_document - should panic ... ok
test validation::tests::verifies_log_id::case_5_new_log_id_for_existing_document - should panic ... ok
test validation::tests::verifies_log_id::case_6_new_public_key_not_next_log_id - should panic ... ok
test validation::tests::verifies_log_id::case_7_new_document_occupied_log_id - should panic ... ok
test validation::tests::verifies_log_id::case_8_new_document_not_next_log_id - should panic ... ok
test validation::tests::verifies_seq_num::case_1_valid_seq_num ... ok
test validation::tests::verifies_seq_num::case_2_seq_num_already_used - should panic ... ok
test validation::tests::verifies_seq_num::case_3_seq_num_too_high - should panic ... ok
test validation::tests::verifies_seq_num::case_4_seq_num_too_high - should panic ... ok
test validation::tests::verifies_seq_num::case_5_no_seq_num - should panic ... ok
failures:
---- materializer::service::tests::materialize_complex_documents stdout ----
-------------- TEST START --------------
thread 'materializer::service::tests::materialize_complex_documents' panicked at 'We expect that the document is `Some`', aquadoggo/src/materializer/service.rs:483:18
---- materializer::service::tests::materialize_document_from_bus stdout ----
-------------- TEST START --------------
thread 'materializer::service::tests::materialize_document_from_bus' panicked at 'We expect that the document is `Some`', aquadoggo/src/materializer/service.rs:234:18
thread 'materializer::service::tests::materialize_document_from_bus' panicked at 'Failed removing completed task from database: Transaction("attempted to acquire a connection on a closed pool")', aquadoggo/src/materializer/service.rs:64:26
---- materializer::service::tests::materialize_update_document stdout ----
-------------- TEST START --------------
thread 'materializer::service::tests::materialize_update_document' panicked at 'assertion failed: `(left == right)`
  left: `String("panda")`,
 right: `String("panda123")`', aquadoggo/src/materializer/service.rs:409:13
failures:
    materializer::service::tests::materialize_complex_documents
    materializer::service::tests::materialize_document_from_bus
    materializer::service::tests::materialize_update_document
test result: FAILED. [238](https://github.com/p2panda/aquadoggo/actions/runs/4304615038/jobs/7505892372#step:6:238) passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 195.40s
error: test failed, to rerun pass `--lib`
Error: The process '/home/runner/.cargo/bin/cargo' failed with exit code 101

@sandreae
Copy link
Member Author

sandreae commented Mar 1, 2023

And it looks like they're running three times..? that seems weird!

@adzialocha adzialocha mentioned this pull request Mar 6, 2023
4 tasks
@sandreae sandreae marked this pull request as ready for review March 14, 2023 14:21
@sandreae sandreae merged commit 335be5a into main Mar 14, 2023
@sandreae sandreae deleted the do-transactions-differently branch March 14, 2023 14:23
adzialocha added a commit that referenced this pull request Mar 16, 2023
* main:
  Update breaking API calls for new `p2panda-rs` version (#293)
  Update Cargo.lock as well
  Use released p2panda-rs version 0.7.0
  Migrate CLI from `structopt` to `clap` (#289)
  Increase timeout for failing materializer test
  Introduce requeue flag (#286)
  Do transactions correctly (#285)
  Add libp2p service and configuration (#282)
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.

Using sqlx::Transaction incorrectly
1 participant