Better database file design #53
Labels
No labels
Kind/Bug
Kind/Enhancement
Kind/Feature
Project/Lander
Project/Landerctl
idea
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Chewing_Bever/lander#53
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'd like to change to CouchDB's database design.
This technique makes the file system resilient to crashes. If a crash occurs while a transaction is being written, its data is simply forgotten on startup. Only data appended by a valid header is part of the database.
This would remove the need for the index file, as we can simply read the database file from left to right on startup.
Updates to entries get handled the same way as inserts. On startup, we insert each entry into the in-memory trie, overwriting an already existing entry.
Of course, this sort of design should ideally go paired with some compact mechanism, as the file can only ever grow.
I'm also reconsidering storing all data inside the database file. This could allow the database to be a single file at all times, but it would mean the file could grow considerably if large data files are uploaded.
The very first thing that's written to the database is the database version. This covers my ass in case I ever want to redesign the database a third time and simplify migrations.
We could even take it a step further and use a page-based approach with a free list, similar to Sqlite. This would allow as to reuse parts of the file as needed. The page size would be written into the first page of the file, next to the database version. This would also allow resizing a datatabase as needed with different page sizes.