-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes 3517: job to retry existing failed tasks (#556)
Fixes 3517: job to retry failed tasks
- Loading branch information
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/content-services/content-sources-backend/pkg/config" | ||
"github.com/content-services/content-sources-backend/pkg/db" | ||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
func main() { | ||
args := os.Args | ||
config.Load() | ||
config.ConfigureLogging() | ||
err := db.Connect() | ||
|
||
if err != nil { | ||
log.Panic().Err(err).Msg("Failed to connect to database") | ||
} | ||
|
||
if len(args) < 2 || args[1] != "--force" { | ||
log.Fatal().Msg("Requires arguments: --force") | ||
} | ||
|
||
query := | ||
` | ||
UPDATE tasks | ||
SET next_retry_time = statement_timestamp(), retries = 0 | ||
WHERE started_at IS NOT NULL AND finished_at IS NOT NULL | ||
AND status = 'failed' AND type = 'delete-repository-snapshots'; | ||
` | ||
result := db.DB.Exec(query) | ||
if result.Error != nil { | ||
log.Fatal().Err(result.Error).Msg("Could not update failed tasks.") | ||
} else { | ||
log.Warn().Msgf("Updated %v tasks", result.RowsAffected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters