Skip to content

Commit

Permalink
MB-27607 - mossStore should delete half-written files on an error
Browse files Browse the repository at this point in the history
Logs to track files and files to remove on openStore

Change-Id: I5e3fd019f9553e4b7ea460413f191427d280761a
Reviewed-on: http://review.couchbase.org/87967
Well-Formed: Build Bot <build@couchbase.com>
Reviewed-by: Sundar Sridharan <sundar@couchbase.com>
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Sreekanth Sivasankaran <sreekanth.sivasankaran@couchbase.com>
  • Loading branch information
sreekanth-cb committed Jan 21, 2018
1 parent 010c989 commit 0947f84
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion store.go
Expand Up @@ -574,6 +574,10 @@ func openStore(dir string, options StoreOptions) (*Store, error) {
}

sort.Strings(fnames)
if options.CollectionOptions.Log != nil {
options.CollectionOptions.Log("store: openStore,"+
" files found: %q", fnames)
}

for i := len(fnames) - 1; i >= 0; i-- {
var flag int
Expand Down Expand Up @@ -605,7 +609,13 @@ func openStore(dir string, options StoreOptions) (*Store, error) {
}

if !options.KeepFiles {
err := removeFiles(dir, append(fnames[0:i], fnames[i+1:]...))
rmFiles := append(fnames[0:i], fnames[i+1:]...)
if options.CollectionOptions.Log != nil {
options.CollectionOptions.Log("store: openStore,"+
" files to remove: %q", rmFiles)
}

err := removeFiles(dir, rmFiles)
if err != nil {
footer.Close()
return nil, err
Expand Down

0 comments on commit 0947f84

Please sign in to comment.