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

File locks flaky on Windows? #449

Closed
casey opened this issue Nov 25, 2022 · 7 comments
Closed

File locks flaky on Windows? #449

casey opened this issue Nov 25, 2022 · 7 comments

Comments

@casey
Copy link
Contributor

casey commented Nov 25, 2022

I've been working on enabling Windows CI for ord, and I'm getting some strange Database already open. Cannot acquire lock. errors. The code is unmodified between unix and windows, so I'm wondering if the file locking/unlocking code on windows is working correctly. The errors are inconsistent, so the same test might pass or fail with no code changes on different runs.

@cberner
Copy link
Owner

cberner commented Nov 25, 2022

I'm pretty sure this is a race in your tests. I added some debug logging, ran it on a Windows laptop, and it shows that you're opening "regtest\index.redb" a second time before the first one is closed. I can make a branch with the code, if you need

@casey
Copy link
Contributor Author

casey commented Nov 25, 2022

Oh nice, good find! I'll look into it. Any idea why this would pass on Linux/MacOS but fail on Windows? Maybe there's a difference in semantics between the two platforms.

@casey casey closed this as completed Nov 25, 2022
@casey
Copy link
Contributor Author

casey commented Nov 25, 2022

I can make a branch with the code, if you need

Yah, that'd be great.

@cberner
Copy link
Owner

cberner commented Nov 25, 2022

Done. See the ord_windows branch

@cberner
Copy link
Owner

cberner commented Nov 25, 2022

Any idea why this would pass on Linux/MacOS but fail on Windows? Maybe there's a difference in semantics between the two platforms.

Not sure. It looks like your tests maybe spawn background processes though? If so, perhaps you need to do something extra to wait for them to finish on Windows

@casey
Copy link
Contributor Author

casey commented Dec 2, 2022

Figured it out: We're using dirs::data_dir() to determine where to put the ord index. dirs::data_dir() consults $HOME, so during tests we set the $HOME variable to point to a tempdir. This doesn't work on Windows, so tests wind up using the same data directory.

Thanks for pushing that branch with debug statements!

@cberner
Copy link
Owner

cberner commented Dec 3, 2022

Ah nice. Ya, for sure!

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

No branches or pull requests

2 participants