Skip to content

Comments

Add check_reserved_lock method.#68

Merged
carlsverre merged 2 commits intoorbitinghail:mainfrom
bkoropoff:check-reserved-lock
Feb 20, 2026
Merged

Add check_reserved_lock method.#68
carlsverre merged 2 commits intoorbitinghail:mainfrom
bkoropoff:check-reserved-lock

Conversation

@bkoropoff
Copy link
Contributor

sqlite will call this operation when a database is being concurrently modified, so it must be present and implemented to avoid a null deref or incorrect locking semantics.

sqlite will call this operation when a database is being concurrently
modified, so it must be present and implemented to avoid a null deref
or incorrect locking semantics.
@carlsverre
Copy link
Contributor

This is super interesting - I haven't yet encountered this vfs call from SQLite. Are you sure SQLite calls this method if it's null? Do you have a repro that I can use to test this?

In general, this PR looks fine - although I'm hesitant to default this method to return false as that clearly signals to SQLite that "this process is never holding any locks".

@carlsverre
Copy link
Contributor

Ok, after doing a bit more research, it appears this is triggered (afaict) only when we take a shared lock and discover that a journal file exists. I haven't hit this problem because I keep all journals in memory, which is a Graft property.

Cool, this seems solid for certain kinds of VFS's - mainly ones that allow for durable journals.

As for the function returning false by default... That feels like a footgun. I think I'll just make it a required method so that folks reason about it.

@carlsverre
Copy link
Contributor

Actually, on second thought, the other lock methods are transparent noops already, so the footgun already exists. Will keep your version.

Thanks for the contribution!

@carlsverre carlsverre enabled auto-merge February 20, 2026 04:47
@carlsverre carlsverre merged commit c3be583 into orbitinghail:main Feb 20, 2026
1 check passed
@bkoropoff
Copy link
Contributor Author

I managed to hit this throwing parallel writers at a VFS backend that is ultimately filesystem-backed. I did find the lock methods being defaulted somewhat concerning. Making them mandatory might be a good change for the next incompatible version bump.

@carlsverre
Copy link
Contributor

Thank you for the additional context! I was super concerned that I hadn't hit it yet until I learned when SQLite uses it.

And yeah, I should probably make them mandatory. Appreciate the feedback! Also if you ever want to talk about what you're working on I'd love to hear it! I hang out in the orbitinghail discord here: https://discord.gg/etFk2N9nzC

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

Successfully merging this pull request may close these issues.

2 participants