Skip to content

Commit

Permalink
Fixed the removal of bloat files after vacuum full
Browse files Browse the repository at this point in the history
  • Loading branch information
visill committed Oct 18, 2024
1 parent 5905cda commit 9d5149c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
13 changes: 7 additions & 6 deletions pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ func (database *DatabaseHandler) GetVirtualExpireIndexes(port uint64) (map[strin
if err := rows2.Scan(&xpath); err != nil {
return nil, nil, fmt.Errorf("unable to parse query output %v", err)
}
p1 := strings.Split(xpath, "/")
p2 := p1[len(p1)-1]
p3 := strings.Split(p2, "_")
if len(p3) >= 4 {
p2 = fmt.Sprintf("%s_%s_%s_%s_", p3[0], p3[1], p3[2], p3[3])
}
p2 := ReworkFileName(xpath)
c2[p2] = true
ylogger.Zero.Debug().Str("file", p2).Msg("added")
}
Expand Down Expand Up @@ -175,3 +170,9 @@ func connectToDatabase(port uint64, database string) (*pgx.Conn, error) {
}
return conn, nil
}

func ReworkFileName(str string) string {
p1 := strings.Split(str, "/")
p2 := strings.Join(p1, "_")
return p2
}
14 changes: 2 additions & 12 deletions pkg/proc/delete_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (dh *BasicDeleteHandler) HandleDeleteGarbage(msg message.DeleteMessage) err
func (dh *BasicDeleteHandler) HandleDeleteFile(msg message.DeleteMessage) error {
err := dh.StorageInterractor.DeleteObject(msg.Name)
if err != nil {
ylogger.Zero.Error().AnErr("err", err).Msg("failed to delete file")
ylogger.Zero.Error().AnErr("err", err).Msg("failed to delete file " + msg.Name)
return errors.Wrap(err, "failed to delete file")
}
return nil
Expand Down Expand Up @@ -123,7 +123,7 @@ func (dh *BasicDeleteHandler) ListGarbageFiles(msg message.DeleteMessage) ([]str

filesToDelete := make([]string, 0)
for i := 0; i < len(objectMetas); i++ {
reworkedName := ReworkFileName(objectMetas[i].Path)
reworkedName := database.ReworkFileName(objectMetas[i].Path)
ylogger.Zero.Debug().Str("reworked name", reworkedName).Msg("lookup chunk")

if vi[reworkedName] {
Expand All @@ -145,13 +145,3 @@ func (dh *BasicDeleteHandler) ListGarbageFiles(msg message.DeleteMessage) ([]str

return filesToDelete, nil
}

func ReworkFileName(str string) string {
p1 := strings.Split(str, "/")
p2 := p1[len(p1)-1]
p3 := strings.Split(p2, "_")
if len(p3) >= 4 {
p2 = fmt.Sprintf("%s_%s_%s_%s_", p3[0], p3[1], p3[2], p3[3])
}
return p2
}

0 comments on commit 9d5149c

Please sign in to comment.