fix: increase default delete retention to 15 months (#10252)
365 + 90 days = 10920h. Also, actually enforce the minimum interval of 24h.
This commit is contained in:
@@ -155,7 +155,7 @@ type serveCmd struct {
|
|||||||
Audit bool `help:"Write events to audit file" env:"STAUDIT"`
|
Audit bool `help:"Write events to audit file" env:"STAUDIT"`
|
||||||
AuditFile string `name:"auditfile" help:"Specify audit file (use \"-\" for stdout, \"--\" for stderr)" placeholder:"PATH" env:"STAUDITFILE"`
|
AuditFile string `name:"auditfile" help:"Specify audit file (use \"-\" for stdout, \"--\" for stderr)" placeholder:"PATH" env:"STAUDITFILE"`
|
||||||
DBMaintenanceInterval time.Duration `help:"Database maintenance interval" default:"8h" env:"STDBMAINTENANCEINTERVAL"`
|
DBMaintenanceInterval time.Duration `help:"Database maintenance interval" default:"8h" env:"STDBMAINTENANCEINTERVAL"`
|
||||||
DBDeleteRetentionInterval time.Duration `help:"Database deleted item retention interval" default:"4320h" env:"STDBDELETERETENTIONINTERVAL"`
|
DBDeleteRetentionInterval time.Duration `help:"Database deleted item retention interval" default:"10920h" env:"STDBDELETERETENTIONINTERVAL"`
|
||||||
GUIAddress string `name:"gui-address" help:"Override GUI address (e.g. \"http://192.0.2.42:8443\")" placeholder:"URL" env:"STGUIADDRESS"`
|
GUIAddress string `name:"gui-address" help:"Override GUI address (e.g. \"http://192.0.2.42:8443\")" placeholder:"URL" env:"STGUIADDRESS"`
|
||||||
GUIAPIKey string `name:"gui-apikey" help:"Override GUI API key" placeholder:"API-KEY" env:"STGUIAPIKEY"`
|
GUIAPIKey string `name:"gui-apikey" help:"Override GUI API key" placeholder:"API-KEY" env:"STGUIAPIKEY"`
|
||||||
LogFile string `name:"log-file" aliases:"logfile" help:"Log file name (see below)" default:"${logFile}" placeholder:"PATH" env:"STLOGFILE"`
|
LogFile string `name:"log-file" aliases:"logfile" help:"Log file name (see below)" default:"${logFile}" placeholder:"PATH" env:"STLOGFILE"`
|
||||||
|
|||||||
@@ -17,14 +17,17 @@ import (
|
|||||||
"github.com/syncthing/syncthing/internal/slogutil"
|
"github.com/syncthing/syncthing/internal/slogutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxDBConns = 16
|
const (
|
||||||
|
maxDBConns = 16
|
||||||
|
minDeleteRetention = 24 * time.Hour
|
||||||
|
)
|
||||||
|
|
||||||
type DB struct {
|
type DB struct {
|
||||||
|
*baseDB
|
||||||
|
|
||||||
pathBase string
|
pathBase string
|
||||||
deleteRetention time.Duration
|
deleteRetention time.Duration
|
||||||
|
|
||||||
*baseDB
|
|
||||||
|
|
||||||
folderDBsMut sync.RWMutex
|
folderDBsMut sync.RWMutex
|
||||||
folderDBs map[string]*folderDB
|
folderDBs map[string]*folderDB
|
||||||
folderDBOpener func(folder, path string, deleteRetention time.Duration) (*folderDB, error)
|
folderDBOpener func(folder, path string, deleteRetention time.Duration) (*folderDB, error)
|
||||||
@@ -36,7 +39,11 @@ type Option func(*DB)
|
|||||||
|
|
||||||
func WithDeleteRetention(d time.Duration) Option {
|
func WithDeleteRetention(d time.Duration) Option {
|
||||||
return func(s *DB) {
|
return func(s *DB) {
|
||||||
s.deleteRetention = d
|
if d <= 0 {
|
||||||
|
s.deleteRetention = 0
|
||||||
|
} else {
|
||||||
|
s.deleteRetention = max(d, minDeleteRetention)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
internalMetaPrefix = "dbsvc"
|
internalMetaPrefix = "dbsvc"
|
||||||
lastMaintKey = "lastMaint"
|
lastMaintKey = "lastMaint"
|
||||||
defaultDeleteRetention = 180 * 24 * time.Hour
|
|
||||||
minDeleteRetention = 24 * time.Hour
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *DB) Service(maintenanceInterval time.Duration) suture.Service {
|
func (s *DB) Service(maintenanceInterval time.Duration) suture.Service {
|
||||||
|
|||||||
+2
-2
@@ -15,8 +15,8 @@
|
|||||||
line options have been removed and will be ignored if given.
|
line options have been removed and will be ignored if given.
|
||||||
|
|
||||||
- Deleted items are no longer kept forever in the database, instead they are
|
- Deleted items are no longer kept forever in the database, instead they are
|
||||||
forgotten after six months. If your use case require deletes to take
|
forgotten after fifteen months. If your use case require deletes to take
|
||||||
effect after more than a six month delay, set the
|
effect after more than a fifteen month delay, set the
|
||||||
`--db-delete-retention-interval` command line option or corresponding
|
`--db-delete-retention-interval` command line option or corresponding
|
||||||
environment variable to zero, or a longer time interval of your choosing.
|
environment variable to zero, or a longer time interval of your choosing.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user