Created
March 10, 2020 14:32
-
-
Save mschoch/2101e4f5a434b6c1c818218a67952cb6 to your computer and use it in GitHub Desktop.
reproduce deleted files still open (as shown by lsof)
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
package main | |
import ( | |
"github.com/blevesearch/bleve" | |
"github.com/blevesearch/bleve/index/scorch" | |
"log" | |
) | |
func main() { | |
m := bleve.NewIndexMapping() | |
idx, err := bleve.NewUsing("rollback.bleve", m, "scorch", "scorch", nil) | |
if err != nil { | |
log.Fatal(err) | |
} | |
err = idx.Index("1", map[string]string{ | |
"name": "1", | |
}) | |
if err != nil{ | |
log.Fatal(err) | |
} | |
err = idx.Index("2", map[string]string{ | |
"name": "1", | |
}) | |
if err != nil{ | |
log.Fatal(err) | |
} | |
// originally i had a sleep here, but removing it | |
// was key to demonstrating the issue | |
//log.Printf("sleeping for 5") | |
//time.Sleep(5*time.Second) | |
idxInternal, _, err := idx.Advanced() | |
if err != nil { | |
log.Fatal(err) | |
} | |
idxScorch := idxInternal.(*scorch.Scorch) | |
rps, err := idxScorch.RollbackPoints() | |
if err != nil { | |
log.Fatal(err) | |
} | |
log.Printf("rps: %v", rps) | |
log.Printf("starting rollback") | |
err = idxScorch.Rollback(rps[0]) | |
if err != nil { | |
log.Fatal(err) | |
} | |
log.Printf("finished rollback") | |
log.Printf("waiting forever") | |
select {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run the program, it will say running forever, in another terminal, find the pid, and observe that segments 2 and 3 are still open, but in the DEL state, looking at the file system they are gone.