-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixes #1847 Currently, `DB.Sync()` only syncs the value log but not the WAL of the active memtable, however recovery happens from the WAL of the active memtable as a part of the `DB.Open()` method. This change attempts to sync both the logs, however there can be an issue in syncing one of the logs. This change lists all of the possible cases that can arise during the sync operations. Some of these issues will be taken separately. For example, the issue #1954 can arise and shall be handled separately. This change adds a few tests to ensure that the Sync behavior is not broken. This change also adds a learning test `(db2_test.go -> TestAssertValueLogIsNotWrittenToOnStartup)` to ensure that value log is only read from (and not written to) during startup. This learning shall be used in the next issue (the one described above (*))
- Loading branch information
1 parent
f9b9e4d
commit 4b0d919
Showing
5 changed files
with
210 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package y | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCombineWithBothErrorsPresent(t *testing.T) { | ||
combinedError := CombineErrors(errors.New("one"), errors.New("two")) | ||
require.Equal(t, "one; two", combinedError.Error()) | ||
} | ||
|
||
func TestCombineErrorsWithOneErrorPresent(t *testing.T) { | ||
combinedError := CombineErrors(errors.New("one"), nil) | ||
require.Equal(t, "one", combinedError.Error()) | ||
} | ||
|
||
func TestCombineErrorsWithOtherErrorPresent(t *testing.T) { | ||
combinedError := CombineErrors(nil, errors.New("other")) | ||
require.Equal(t, "other", combinedError.Error()) | ||
} | ||
|
||
func TestCombineErrorsWithBothErrorsAsNil(t *testing.T) { | ||
combinedError := CombineErrors(nil, nil) | ||
require.NoError(t, combinedError) | ||
} |