Skip to content

Conversation

@maitai
Copy link

@maitai maitai commented Nov 24, 2022

This PR adds a ReadOnly config option to be able to put the database on a read-only filesystem.
Enabling this config options disables the Lockfile mechanism and sets all file access flags to O_RDONLY.

@maitai maitai marked this pull request as ready for review November 25, 2022 09:49
Copy link
Owner

@akrylysov akrylysov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! I left a few comments.


func writeGobFile(fsys fs.FileSystem, name string, v interface{}) error {
f, err := openFile(fsys, name, true)
func writeGobFile(fsys fs.FileSystem, name string, v interface{}, readOnly bool) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the desired effect of writing to a file opened in read-only mode? Wouldn't it always fail?


func (dl *datalog) openSegment(name string, id uint16, seqID uint64) (*segment, error) {
f, err := openFile(dl.opts.FileSystem, name, false)
f, err := openFile(dl.opts.FileSystem, name, false, dl.opts.ReadOnly)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if rather than modifying all openFile calls it would be cleaner to implement a new file system wrapper similar to fs.Sub? The wrapper would set os.O_RDONLY flags and implement a noop CreateLockFile.

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