π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[server] Fixed delay in next attemp
Neeraj Guptac6ec3fa8fde6
diff --git a/server/pkg/controller/replication3.go b/server/pkg/controller/replication3.goindex c7b52ff870..a57a372fab 100644--- a/server/pkg/controller/replication3.go+++ b/server/pkg/controller/replication3.go@@ -250,6 +250,16 @@ func (c *ReplicationController3) tryReplicate() error {logger.Error(err)}+ if strings.Contains(err.Error(), "size of the uploaded file") {+ delayErr := c.ObjectCopiesRepo.DelayNextAttemptByDays(context.Background(), objectKey, 7)+ if delayErr != nil {+ logger.WithError(delayErr).Error("Failed to delay next attempt by 7 days")+ } else {+ discordAlert := fmt.Sprintf("π₯ Size mismatch for object %s, failed to delay next attempt by 7 days", objectKey)+ c.notifyDiscord(discordAlert)+ }+ }+if err == nil {logger.Info("Replication attempt succeeded")} else {diff --git a/server/pkg/repo/object_copies.go b/server/pkg/repo/object_copies.goindex 31443e25c5..33245740f8 100644--- a/server/pkg/repo/object_copies.go+++ b/server/pkg/repo/object_copies.go@@ -35,7 +35,6 @@ func (repo *ObjectCopiesRepository) GetAndLockUnreplicatedObject(ctx context.Con}}- // todo:(neeraj) reduce the gap between last_attempt and now_utc_micro_seconds from 7 days to 1 dayrow := tx.QueryRowContext(ctx, `SELECT object_key, want_b2, b2, want_wasabi, wasabi, want_scw, scwFROM object_copies@@ -43,7 +42,7 @@ func (repo *ObjectCopiesRepository) GetAndLockUnreplicatedObject(ctx context.Con((wasabi IS NULL AND want_wasabi = true) OR(scw IS NULL AND want_scw = true)- ) AND last_attempt < (now_utc_micro_seconds() - (7* 24::BIGINT * 60 * 60 * 1000 * 1000))+ ) AND last_attempt < (now_utc_micro_seconds() - (24::BIGINT * 60 * 60 * 1000 * 1000)))LIMIT 1FOR UPDATE SKIP LOCKED@@ -112,6 +111,15 @@ func (repo *ObjectCopiesRepository) RegisterReplicationAttempt(tx *sql.Tx, ctx creturn stacktrace.Propagate(err, "")}+func (repo *ObjectCopiesRepository) DelayNextAttemptByDays(ctx context.Context, objectKey string, days int) error {+ _, err := repo.DB.ExecContext(ctx, `+ UPDATE object_copies+ SET last_attempt = last_attempt + ($2 * 24::BIGINT * 60 * 60 * 1000 * 1000)+ WHERE object_key = $1+ `, objectKey, days)+ return stacktrace.Propagate(err, "")+}+// ResetNeedsB2Replication modifies the db to indicate that objectKey should be// re-replicated to Backblaze even if it has already been replicated there.func (repo *ObjectCopiesRepository) ResetNeedsB2Replication(objectKey string) error {