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

add tests for transact in multi-threaded behaviour #488

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

Horusiath
Copy link
Collaborator

No description provided.

@Horusiath Horusiath mentioned this pull request Aug 26, 2024
let t = txt.clone();
let b = barrier.clone();
std::thread::spawn(move || {
// let mut txn = d.try_transact_mut().unwrap(); // this will hang forever
Copy link
Contributor

Choose a reason for hiding this comment

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

From this comment:

  1. Transact::transact and Transact::transact_mut methods now won't panic when transaction couldn't be acquired. Instead they will block a thread. You can always simulate old behaviour by using doc.try_transact().unwrap().

I understood that d.try_transact_mut().unwrap() will panic (for all other threads after the first one acquired the transaction), not that it will hang forever?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case it will hang forever, since panic inside of the thread will prevent execution of barrier.wait(), which means that we won't be able to pass over the barrier on the main test thread.

Copy link
Contributor

@davidbrochart davidbrochart left a comment

Choose a reason for hiding this comment

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

Thanks!

@Horusiath Horusiath merged commit b02fe3d into y-crdt:main Aug 27, 2024
8 checks passed
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.

2 participants