Comments (7)
you implemented the database, right?
Yes.
Microsoft doesn't really support parallel database queries, which is why we often lock database retrievals to ensure there are no collisions.
Yes.
As I saw in the code, we connect to the database only once and from then on, we just send commands to it.
Yes. That was an intentional design choice at the time of implementation. More can be read here.
My suggestion would be to connect to the database with every command we send, and then disconnect from it once we're done, because we can't know when and on what thread we might want to access the file, especially if some error occurs. In that case, the program is likely to keep the file open when it shouldn't.
I don't follow this train of thought. I would recommend to read #10272 (comment) so that we are on the same page with regards to what we want from that SQLite database.
But I would like to point out that your approach has a potential downside as well - notably: Suppose that WW works as you suggest and then suppose that at some point you don't need the database, so there is no active connection to it. And suppose that some external process opens that sqlite database with an exclusive lock1, then very likely you can crash WW because it will be unable to work with the database. That was one of the reasons why I implemented single connection that has the same lifetime as the application itself, because once you start the application and it initializes, you know it will keep working. At least, that's the idea behind it.
In that case, the program is likely to keep the file open when it shouldn't.
I don't follow this. If the program refers to WW, then WW is supposed to be able to be run just once (because we don't allow to run two instances at the same time). Then the one (and only) instance connects to the SQLite database and releases the connection when it crashes (because when a program crashes, OS cleans up file descriptors and releases resources, so next time you should be able to start WW just fine).
Can we do a test on this?
I would prefer to understand first why you think it should fix this issue. I don't think it will fix this issue. However, if you are right, i guess you can repro this issue easily by crashing WW and then trying to start WW again.
This is my take. Feel free to point out if I'm wrong on any point.
edit: If I were to guess, what this is about, I would guess that an antivirus program scans files and Wasabi attempts to start to find out that the file is locked and crashes. This would explain also #11873. But that would be only a good explanation if you one would observe:
- Start WW
- Crash
- Start WW again
- No crash.
but I'm not sure if that's what people observe.
Another explanation might be that our check for starting WW multiple times does not work correctly in all cases2 and user succeeds in starting WW twice, then the second instance should crash, or maybe both instances based on conditions.
Another explanation might be that we initialize stuff incorrectly but I don't observe this on my machine.
Footnotes
-
I tried to open
IndexStore.sqlite
in SQLite browser and executeSELECT block_height as h2 FROM filter WHERE h2 = (SELECT count(*) from filter where block_height < h2)
which takes a very long time and even then I'm able to start WW, I tried to simulate a bit a transaction with writing but I'm not sure if it was correct, but still no crash on WW side. ↩ -
I just tried
cd WalletWasabi/WalletWasabi.Fluent.Desktop;
and then.\bin\Debug\net7.0\WalletWasabi.Fluent.Desktop.exe &; .\bin\Debug\net7.0\WalletWasabi.Fluent.Desktop.exe &
in PowerShell to run two instances of the app in parallel and I don't observe any crash. ↩
from walletwasabi.
Maybe there is a process that has locked your database.
One approach is to find the process that has locked your file (see an answer) to get to the bottom of this.
The other approach is just to restart your machine and thus making sure that no such process can exist.
from walletwasabi.
@kiminuo you implemented the database, right? Microsoft doesn't really support parallel database queries, which is why we often lock database retrievals to ensure there are no collisions. As I saw in the code, we connect to the database only once and from then on, we just send commands to it. My suggestion would be to connect to the database with every command we send, and then disconnect from it once we're done, because we can't know when and on what thread we might want to access the file, especially if some error occurs. In that case, the program is likely to keep the file open when it shouldn't. I think the best and most sensible solution is not to have a constant connection to the SQLite database, but only when we want to start doing something with it. Can we do a test on this?
from walletwasabi.
Okay, you're right. Thank you for the explanation, and I have read the topics where similar thoughts were discussed, so I also consider this part closed on my end. But if opening the file sometimes causes problems in several areas, maybe at the start of the program, we should do a preliminary check to see if all the files we're going to lock are accessible?
You are also right that this is currently not a high-priority task, but if I receive a message from the user side that I need to restart my computer, that's a bad policy, I think.
from walletwasabi.
But if opening the file sometimes causes problems in several areas, maybe at the start of the program, we should do a preliminary check to see if all the files we're going to lock are accessible?
I tend to think that it's not correct because it feels like the solution would be similar to:
if (File.Exists(path)) { // (1)
var f = File.Open(path, ..); // Here it's not guaranteed that the file exists because it might have been deleted after line (1)
}
That is to say, you can do the check, something locks your file, and the issue is there again. So the approach "narrows down the window where the issue might happen" but it does not feel like a robust solution to me. But then improving the message we report to user might be good.
You are also right that this is currently not a high-priority task
I didn't say that.
I think we need clear instructions how to reproduce the issue then we can fix it. Otherwise, we are just chasing ghosts. I was thinking about it and maybe we can set up a virtual machine with Windows, install WW there and run it to see if Defender locks files. But it's a long shot.
from walletwasabi.
Should be fixed with #12878.
Edit: Very likely a duplicate of #11638.
from walletwasabi.
from walletwasabi.
Related Issues (20)
- Keeps hanging, HOT 3
- Switch to Taproot by default HOT 8
- Update SECURITY.md HOT 2
- Crashes after a short while HOT 2
- Multiple Wasabi app at the same time HOT 3
- UI glitch on privacy progress. HOT 1
- Still zkSNACKs mentioned everywhere
- Autoupdater shows version 0.0.0 HOT 4
- wasabi wallet HOT 1
- Autoupdater suggests to update but not to the latest version HOT 1
- Label CJs with a coordinator identifier, like domain name.
- No attempt to connect to Tor was successful HOT 1
- Wasabi Wallet v 2.1.0 crashing while in Coinjoin process - OS: Windows 11 Ver 23H2 Build 22631.3880 HOT 5
- Placeholder value for Plebs Don't Pay HOT 1
- New Crash HOT 1
- crash HOT 1
- Hi HOT 5
- cannot build v2.1.0.0 from source: Warning As Error: Package 'System.Text.Json' 8.0.3 has a known high severity vulnerability
- No attempt to connect to Tor was successful. HOT 1
- "Max coordinator fee rate" does not have a unit HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from walletwasabi.