close file and refactor function (#185)

* close file
This commit is contained in:
xiongjiwei 2020-05-28 13:04:18 +08:00 committed by GitHub
parent bc06cdf987
commit 16b8058220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -55,7 +55,7 @@ func ErrRespRegionNotFound(regionID uint64) *raft_cmdpb.RaftCmdResponse {
}
}
func newCmdRespForReq(req *raft_cmdpb.RaftCmdRequest) *raft_cmdpb.RaftCmdResponse {
func newCmdResp() *raft_cmdpb.RaftCmdResponse {
return &raft_cmdpb.RaftCmdResponse{
Header: &raft_cmdpb.RaftResponseHeader{},
}

View File

@ -690,6 +690,9 @@ func (s *Snap) Apply(opts ApplyOptions) error {
externalFiles = append(externalFiles, file)
}
n, err := opts.DB.IngestExternalFiles(externalFiles)
for _, file := range externalFiles {
file.Close()
}
if err != nil {
log.Errorf("ingest sst failed (first %d files succeeded): %s", n, err)
return err