Skip to content

Commit

Permalink
Log TBWR failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei Pleshakov committed Nov 12, 2024
1 parent b064fbf commit eb85906
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions internal/handlers/take_backup_retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TBWROperationHandler(
queryBuilderFactory queries.WriteQueryBulderFactory,
clock clockwork.Clock,
) error {
xlog.Info(ctx, "TBWROperationHandler", zap.String("OperationID", operation.GetID()))
ctx = xlog.With(ctx, zap.String("OperationID", operation.GetID()))

if operation.GetType() != types.OperationTypeTBWR {
return fmt.Errorf("wrong operation type %s != %s", operation.GetType(), types.OperationTypeTBWR)
Expand Down Expand Up @@ -187,12 +187,13 @@ func TBWROperationHandler(
}
return err
}
xlog.Info(
ctx,
"TBWROperationHandler",
zap.String("OperationID", operation.GetID()),
zap.String("decision", do.String()),
)
if do != Error {
xlog.Info(
ctx,
"TBWROperationHandler",
zap.String("decision", do.String()),
)
}
switch do {
case Success:
{
Expand All @@ -206,10 +207,18 @@ func TBWROperationHandler(
{
tbwr.State = types.OperationStateError
tbwr.Message = "retry attempts exhausted"
fields := []zap.Field{
zap.Int("RetriesCount", len(ops)),
}
if len(ops) > 0 {
fields = append(fields, zap.String("LastTBOperationID", ops[len(ops)-1].GetID()))
}
xlog.Error(ctx, "retry attempts exhausted for TBWR operation", fields...)
return db.ExecuteUpsert(ctx, queryBuilderFactory().WithUpdateOperation(tbwr))
}
case RunNewTb:
{
xlog.Debug(ctx, "running new TB")
backup, tb, err := backup_operations.MakeBackup(
ctx,
clientConn,
Expand Down Expand Up @@ -237,6 +246,7 @@ func TBWROperationHandler(
//if has last and not cancelled: set start_cancelling to it, skip
//if cancelled, set cancelled to itself
{
xlog.Info(ctx, "cancelling TBWR operation")
if len(tbOps) == 0 {
tbwr.State = types.OperationStateCancelled
tbwr.Message = "Success"
Expand All @@ -249,6 +259,7 @@ func TBWROperationHandler(
return db.ExecuteUpsert(ctx, queryBuilderFactory().WithUpdateOperation(tbwr))
} else {
if last.State == types.OperationStatePending || last.State == types.OperationStateRunning {
xlog.Info(ctx, "cancelling TB operation", zap.String("TBOperationID", last.ID))
last.State = types.OperationStateStartCancelling
last.Message = "Cancelling by parent operation"
return db.ExecuteUpsert(ctx, queryBuilderFactory().WithUpdateOperation(last))
Expand Down

0 comments on commit eb85906

Please sign in to comment.