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

Fix flushing logic and add functional test case. #113

Merged
merged 4 commits into from
Feb 11, 2019
Merged

Conversation

notbdu
Copy link
Collaborator

@notbdu notbdu commented Feb 8, 2019

Fixes #107 and #108.

Also adds a functional test case that repros both issues.

@@ -27,18 +27,22 @@ var (

// segmentWriter is responsible for writing segments to filesystem.
type segmentWriter interface {
// Open opens the writer.
Open(opts writerOpenOptions) error
// Start persisting data to disk.
Copy link
Owner

Choose a reason for hiding this comment

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

nit: Should be a sentence, e.g., Start starts persisting a segment.

// Start persisting data to disk.
Start(opts writerStartOptions) error

// Finish persisting data to disk.
Copy link
Owner

Choose a reason for hiding this comment

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

Finish finishes persisting a segment and performs cleanups as necessary.

return err
}

if err := d.Options().PersistManager().Close(); err != nil {
Copy link
Owner

Choose a reason for hiding this comment

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

This may need to wait till the current ticking finishes (which may perform a flush). Is that the case at the moment?

Copy link
Owner

Choose a reason for hiding this comment

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

On a second thought this probably should just be removed, as closing the manager will cause the it to panic if it's in the middle of a flush, and all closing does is just setting some nil pointers (which doesn't matter much if the database is shutting down).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removing the close completely.

"github.com/stretchr/testify/require"
)

func TestFlush(t *testing.T) {
Copy link
Owner

Choose a reason for hiding this comment

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

Fine to leave this here for now, but this looks like an integration test rather than a unit test (which typically tests local functionalities than performing an end-to-end test).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I put it here to access internal structs to force a flush.

Copy link
Owner

@xichen2020 xichen2020 left a comment

Choose a reason for hiding this comment

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

LGTM

@xichen2020 xichen2020 merged commit e0d1341 into master Feb 11, 2019
@xichen2020 xichen2020 deleted the bdu/flushfix branch February 11, 2019 17:03
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