Skip to content

Commit

Permalink
Use a different crate name in a test to prevent deadlocks
Browse files Browse the repository at this point in the history
This test does a lot of different manipulations of categories and crate
categories and it was using a crate named foo. The good_categories test
also used a crate named foo, and these two tests were causing a postgres
deadlock.

I was able to cause deadlocks more often by duplicating the update_crate
test and the good_categories test:

https://travis-ci.org/integer32llc/crates.io/builds/187302718

Making this change and running the duplicated tests resulted in 0
deadlocks:

https://travis-ci.org/integer32llc/crates.io/builds/187306433

This is unlikely to happen in production; requests get a database
connection that gets closed when the request finishes, and the publish
request only modifies the categories once, not as much as the
update_crate test is. It seems unlikely that two people would publish
the same crate at exactly the same time.
  • Loading branch information
carols10cents committed Dec 28, 2016
1 parent c2d5cf8 commit c6de914
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/tests/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn update_crate() {
::json::<GoodCategory>(&mut response).category.crates_cnt as usize
};
::mock_user(&mut req, ::user("foo"));
let (krate, _) = ::mock_crate(&mut req, ::krate("foo"));
let (krate, _) = ::mock_crate(&mut req, ::krate("foocat"));
::mock_category(&mut req, "cat1", "cat1");
::mock_category(&mut req, "Category 2", "category-2");

Expand Down

0 comments on commit c6de914

Please sign in to comment.