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

Protect the cache lock better #3604

Merged
merged 4 commits into from
Jan 29, 2024

Conversation

dbutenhof
Copy link
Member

PBENCH-1317

We found a case where a cache lock could "leak" when an error occurs reading a file in the visualize and compare APIs. The file read has now been repackaged with a finally to be sure the stream is closed and unlocked on error.

@dbutenhof dbutenhof added bug Server API Of and relating to application programming interfaces to services and functions labels Jan 25, 2024
@dbutenhof dbutenhof requested a review from webbnh January 25, 2024 21:24
@dbutenhof dbutenhof self-assigned this Jan 25, 2024
webbnh

This comment was marked as resolved.

PBENCH-1317

We found a case where a cache lock could "leak" when an error occurs reading a
file in the visualize and compare APIs. The file read has now been repackaged
with a `finally` to be sure the stream is closed and unlocked on error.
Copy link
Member

@webbnh webbnh left a comment

Choose a reason for hiding this comment

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

Looks good. (There's just a nit which we can ignore.)

Comment on lines 97 to 100
datasets = params.query.get("datasets")
benchmark_choice = None
benchmark = None
for dataset in datasets:
Copy link
Member

Choose a reason for hiding this comment

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

While initializing benchmark here certainly doesn't hurt anything, I don't see how it helps anything, either: it is written unconditionally at line 113 before it is tested at line 116, so the initial value is always overwritten (and, benchmark is never read if we don't enter the loop).

Copy link
Member Author

Choose a reason for hiding this comment

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

vscode was unreasonably paranoid about the reference outside the loop, and I pre-declared the thing just to shut it up.

Copy link
Member

Choose a reason for hiding this comment

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

Curious: I didn't see the reference outside the loop (otherwise, I probably would have ratified the paranoia). Still, I don't object to shutting up the linter (I think that's the better alternative to trying to ignore it).

Copy link
Member

Choose a reason for hiding this comment

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

Oh, here it is. Yeah, that reference probably should have been changed to benchmark_choice, rather than expanding the scope of benchmark....

@dbutenhof dbutenhof merged commit e4e3da3 into distributed-system-analysis:main Jan 29, 2024
4 checks passed
@dbutenhof dbutenhof deleted the unlock branch January 29, 2024 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Of and relating to application programming interfaces to services and functions bug Server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants