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 a deadlock in cargo pgrx install during get_git_hash() #1935

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cargo-pgrx/src/command/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ static GIT_HASH: OnceLock<MemoizeKeyValue> = OnceLock::new();
fn get_git_hash(manifest_path: impl AsRef<Path>) -> eyre::Result<String> {
let path_string = manifest_path.as_ref().to_owned();

if let Some(hash) = GIT_HASH.get_or_init(Default::default).lock().unwrap().get(&path_string) {
let mut mutex = GIT_HASH.get_or_init(Default::default).lock().unwrap();
if let Some(hash) = mutex.get(&path_string) {
Ok(hash.clone())
} else {
let hash = match get_property(manifest_path, "git_hash")? {
Expand All @@ -504,7 +505,7 @@ fn get_git_hash(manifest_path: impl AsRef<Path>) -> eyre::Result<String> {
)),
};

GIT_HASH.get_or_init(Default::default).lock().unwrap().insert(path_string, hash.clone());
mutex.insert(path_string, hash.clone());

Ok(hash)
}
Expand Down
Loading