Tweak speed for crons
This commit is contained in:
parent
192caedeb9
commit
e667eef951
2 changed files with 16 additions and 3 deletions
|
@ -855,14 +855,14 @@ func setupAndStartCrons(userAuthRepo *repo.UserAuthRepository, publicCollectionR
|
|||
}
|
||||
})
|
||||
|
||||
schedule(c, "@every 193s", func() {
|
||||
schedule(c, "@every 2m", func() {
|
||||
fileController.CleanupDeletedFiles()
|
||||
})
|
||||
schedule(c, "@every 101s", func() {
|
||||
embeddingCtrl.CleanupDeletedEmbeddings()
|
||||
})
|
||||
|
||||
schedule(c, "@every 120s", func() {
|
||||
schedule(c, "@every 5m", func() {
|
||||
trashController.DropFileMetadataCron()
|
||||
})
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -54,6 +55,9 @@ const MaxFileSize = int64(1024 * 1024 * 1024 * 5)
|
|||
|
||||
// MaxUploadURLsLimit indicates the max number of upload urls which can be request in one go
|
||||
const MaxUploadURLsLimit = 50
|
||||
const (
|
||||
DeletedObjectQueueLock = "deleted_objects_queue_lock"
|
||||
)
|
||||
|
||||
// Create adds an entry for a file in the respective tables
|
||||
func (c *FileController) Create(ctx context.Context, userID int64, file ente.File, userAgent string, app ente.App) (ente.File, error) {
|
||||
|
@ -600,7 +604,16 @@ func (c *FileController) CleanupDeletedFiles() {
|
|||
defer func() {
|
||||
c.cleanupCronRunning = false
|
||||
}()
|
||||
items, err := c.QueueRepo.GetItemsReadyForDeletion(repo.DeleteObjectQueue, 200)
|
||||
|
||||
lockStatus := c.LockController.TryLock(DeletedObjectQueueLock, time.MicrosecondsAfterHours(24))
|
||||
if !lockStatus {
|
||||
log.Warning(fmt.Sprintf("Failed to acquire lock %s", DeletedObjectQueueLock))
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
c.LockController.ReleaseLock(DeletedObjectQueueLock)
|
||||
}()
|
||||
items, err := c.QueueRepo.GetItemsReadyForDeletion(repo.DeleteObjectQueue, 2000)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to fetch items from queue")
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue