khonsulabs / bonsaidb

A developer-friendly document database that grows with you, written in Rust
https://bonsaidb.io/
Apache License 2.0
1.03k stars 37 forks source link

Prevent errors on case-insensitive filesystems #285

Open ecton opened 1 year ago

ecton commented 1 year ago

If a user calls create_database with two differently cased versions of the same name on a case-insensitive filesystem, the underlying Nebari files will be "shared" -- but not in a correct way. They will overwrite each other, causing all sorts of havoc.

There are a few fixes for this. One could be to add this to the list on #251 and migrate away from using the database name in the directory -- maybe use the database id instead.

Another could be to add a check in create_database_without_schema create_database_with_schema that a folder at that path doesn't already exist. This makes the case-insensitivity be enforced by the filesystem rules -- which is understandable once you know how BonsaiDb works, but could still be a surprise to a user.

nerdachse commented 1 year ago

Hey there!

I can only find create_database_with_schema or database_without_schema but not create_database_without_schema in the main branch.

Should I look elsewhere or am I missing something?

Note that I don't plan to really fix this as there is no consensus yet for which solution should be implemented, I merely am curious :)

ecton commented 1 year ago

Sorry for the delay, I accidentally marked the notification as read and then forgot about it!

It looks like this was just me typing from memory and calling it the wrong thing. The function I meant to reference is create_database_with_schema -- both technically have some aspect of the schema specified, one is just generic and one is the SchemaName. Perhaps I should consider renaming it to create_database_with_schema_name.