-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix : read only user should be able to open db on ReadOnly mode #2268
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
Open
Naelpuissant
wants to merge
5
commits into
dgraph-io:main
Choose a base branch
from
Naelpuissant:fix-read-only
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+54
−12
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5361fb7
fix: add checks to avoid unused GC initialization and to make sure to…
Naelpuissant dc2b719
tests: unskip ReadOnly test
Naelpuissant cc7ac72
fix: disable empty vlog deletion on ReadOnly mode
Naelpuissant 12f7f45
Merge branch 'main' into fix-read-only
Naelpuissant 8100d3c
fix: don't create value gc closer to avoid goroutine leak and add mor…
Naelpuissant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1742,8 +1742,6 @@ func TestTestSequence2(t *testing.T) { | |
| } | ||
|
|
||
| func TestReadOnly(t *testing.T) { | ||
| t.Skipf("TODO: ReadOnly needs truncation, so this fails") | ||
|
|
||
| dir, err := os.MkdirTemp("", "badger-test") | ||
| require.NoError(t, err) | ||
| defer removeDir(dir) | ||
|
|
@@ -1771,12 +1769,10 @@ func TestReadOnly(t *testing.T) { | |
| opts.ReadOnly = true | ||
| kv1, err := Open(opts) | ||
| require.NoError(t, err) | ||
| defer kv1.Close() | ||
|
|
||
| // Open another read-only | ||
| kv2, err := Open(opts) | ||
| require.NoError(t, err) | ||
| defer kv2.Close() | ||
|
|
||
| // Attempt a read-write open while it's open for read-only | ||
| opts.ReadOnly = false | ||
|
|
@@ -1793,6 +1789,10 @@ func TestReadOnly(t *testing.T) { | |
| require.Equal(t, b1, []byte("value1")) | ||
| err = txn1.Commit() | ||
| require.NoError(t, err) | ||
| err = kv1.RunValueLogGC(0.5) | ||
| require.Error(t, err, ErrGCInReadOnlyMode) | ||
| err = kv1.Sync() | ||
| require.NoError(t, err) | ||
|
|
||
| // Get a thing from the DB via the other connection | ||
| txn2 := kv2.NewTransaction(true) | ||
|
|
@@ -1811,6 +1811,26 @@ func TestReadOnly(t *testing.T) { | |
| require.Contains(t, err.Error(), "No sets or deletes are allowed in a read-only transaction") | ||
| err = txn.Commit() | ||
| require.NoError(t, err) | ||
|
|
||
| // Close | ||
| require.NoError(t, kv1.Close()) | ||
| require.NoError(t, kv2.Close()) | ||
|
|
||
| // Test os permission read-only open | ||
| // We don't directly chmod the directory to still be able to aquire the lock | ||
| err = os.Chmod(dir, 0o500) | ||
| require.NoError(t, err) | ||
| opts.ReadOnly = true | ||
| kv3, err := Open(opts) | ||
| require.NoError(t, err) | ||
| txn3 := kv3.NewTransaction(true) | ||
| _, err = txn3.Get([]byte("key1")) | ||
| require.NoError(t, err) | ||
| require.NoError(t, kv3.Close()) | ||
| require.NoError(t, txn3.Commit()) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Swap 1830 with 1829, at present commit is called after close, which I guess works because txn3 performed no writes. |
||
|
|
||
| // Restore permissions for cleanup | ||
| require.NoError(t, os.Chmod(dir, 0o700)) | ||
| } | ||
|
|
||
| func TestLSMOnly(t *testing.T) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "acquire"