Skip to content
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

add ReadOnly config option for read-only filesystems #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

@@ -16,8 +16,8 @@ func readGobFile(fsys fs.FileSystem, name string, v interface{}) error {
return dec.Decode(v)
}

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?

@@ -79,15 +79,15 @@ func parseSegmentName(name string) (uint16, uint64, error) {
}

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