-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Implement shared memory BSD locks #85
Comments
This comment was marked as outdated.
This comment was marked as outdated.
So far switching to this library has allowed users on Illumos to now run GoToSocial and since in general this library has a much easier time supporting all platforms the Go compiler supports we'd like to complete that transition. Since this issue affects Illumos too I'm actually a bit worried that user might now have a problem as our default is However, as noted in our previous discussion, we would like to keep the FreeBSD and OpenBSD ports working and we generally prefer to use WAL mode as it tends to be more performant in our case. Could you elaborate a bit on what it would take to implement this? I wouldn't mind taking a stab at it, but I'm not entirely sure where to begin. An implementation built on Go's synchronisation primitives is probably the easiest on me personally, but I can look at other things too if you've got some pointers for me. |
There are a few sides to this. It should be noted that, even if this is fixed, the performance, for most OSes/architechtures, won't be amazing. The wazero compiler is Switching to As for the actual issue, I'd like to solve this, but it's definitely challenging. The major issue is how badly broken POSIX locks are. BSD locks have much better semantics, but don't support multiple locks per file. OFD locks are the best of both worlds. For rollback journal, you can get away with a single lock per file, if you accept: (1) reduced concurrency, (2) writer starvation. So, to synchronize with other processes, we need some kind of file locks, and to synchronize internally we need something in-memory. That's very close to what SQLite did, and it's a PITA to implement. I've spent some time trying to find an angle that's easier but, TBH, haven't found any. Both my suggestions above quickly break down. |
Sleeping over it, I may have a solution that I'm not sure doesn't work. Writing this down so I don't forget. I'll take a look, time permitting. The idea is to make a shm.go for flock.
And This should be possible to test under Linux and macOS with the tag On macOS we must also test if the |
I think that's fine for GoToSocial at least. We don't really expect anyone to be running this on something other than amd|arm64. Maybe risc64 at some point in the future. We only target Linux and the BSDs, anything beyond that is great if it works but not something we make promises about. |
Adds documentation and a configuration validation check to ensure that when folks run with the WASM SQLite build on anything other than Linux we don't allow them to run with journaling set to WAL. That will result in database corruption until ncruces/go-sqlite3#85 is resolved. It's otherwise safe to use the WASM build. Fixes #2962
Adds documentation and a configuration validation check to ensure that when folks run with the WASM SQLite build on anything other than Linux we don't allow them to run with journaling set to WAL. That will result in abysmal performance until ncruces/go-sqlite3#85 is resolved. Fixes #2962
Both the BSDs and illumos support shared memory, but not OFD locks.
Some form of in-memory locks would allow them to (safely) support WAL mode, as long we lock the database file exclusively to prevent other processes from accessing it.
The text was updated successfully, but these errors were encountered: