diff --git a/backend/controller/sql/querier.go b/backend/controller/sql/querier.go index cd6532faad..af4995cb9a 100644 --- a/backend/controller/sql/querier.go +++ b/backend/controller/sql/querier.go @@ -91,7 +91,7 @@ type Querier interface { GetSubscriptionsNeedingUpdate(ctx context.Context) ([]GetSubscriptionsNeedingUpdateRow, error) GetTopic(ctx context.Context, dollar_1 int64) (Topic, error) GetTopicEvent(ctx context.Context, dollar_1 int64) (TopicEvent, error) - GetZombieAsyncCalls(ctx context.Context, limit int32) ([]GetZombieAsyncCallsRow, error) + GetZombieAsyncCalls(ctx context.Context, limit int32) ([]AsyncCall, error) InsertSubscriber(ctx context.Context, arg InsertSubscriberParams) error InsertTimelineCallEvent(ctx context.Context, arg InsertTimelineCallEventParams) error InsertTimelineDeploymentCreatedEvent(ctx context.Context, arg InsertTimelineDeploymentCreatedEventParams) error diff --git a/backend/controller/sql/queries.sql b/backend/controller/sql/queries.sql index 4e0460b177..de8b81d628 100644 --- a/backend/controller/sql/queries.sql +++ b/backend/controller/sql/queries.sql @@ -597,20 +597,7 @@ FROM async_calls WHERE id = @id; -- name: GetZombieAsyncCalls :many -SELECT - id, - origin, - scheduled_at, - verb, - catch_verb, - request, - remaining_attempts, - error, - backoff, - max_backoff, - parent_request_key, - trace_context, - catching +SELECT * FROM async_calls WHERE state = 'executing' AND lease_id IS NULL diff --git a/backend/controller/sql/queries.sql.go b/backend/controller/sql/queries.sql.go index 94d9eff1fc..e4d6819d61 100644 --- a/backend/controller/sql/queries.sql.go +++ b/backend/controller/sql/queries.sql.go @@ -1955,20 +1955,7 @@ func (q *Queries) GetTopicEvent(ctx context.Context, dollar_1 int64) (TopicEvent } const getZombieAsyncCalls = `-- name: GetZombieAsyncCalls :many -SELECT - id, - origin, - scheduled_at, - verb, - catch_verb, - request, - remaining_attempts, - error, - backoff, - max_backoff, - parent_request_key, - trace_context, - catching +SELECT id, created_at, lease_id, verb, state, origin, scheduled_at, request, response, error, remaining_attempts, backoff, max_backoff, catch_verb, catching, parent_request_key, trace_context FROM async_calls WHERE state = 'executing' AND lease_id IS NULL @@ -1976,45 +1963,33 @@ ORDER BY created_at ASC LIMIT $1::INT ` -type GetZombieAsyncCallsRow struct { - ID int64 - Origin string - ScheduledAt time.Time - Verb schema.RefKey - CatchVerb optional.Option[schema.RefKey] - Request encryption.EncryptedAsyncColumn - RemainingAttempts int32 - Error optional.Option[string] - Backoff sqltypes.Duration - MaxBackoff sqltypes.Duration - ParentRequestKey optional.Option[string] - TraceContext pqtype.NullRawMessage - Catching bool -} - -func (q *Queries) GetZombieAsyncCalls(ctx context.Context, limit int32) ([]GetZombieAsyncCallsRow, error) { +func (q *Queries) GetZombieAsyncCalls(ctx context.Context, limit int32) ([]AsyncCall, error) { rows, err := q.db.QueryContext(ctx, getZombieAsyncCalls, limit) if err != nil { return nil, err } defer rows.Close() - var items []GetZombieAsyncCallsRow + var items []AsyncCall for rows.Next() { - var i GetZombieAsyncCallsRow + var i AsyncCall if err := rows.Scan( &i.ID, + &i.CreatedAt, + &i.LeaseID, + &i.Verb, + &i.State, &i.Origin, &i.ScheduledAt, - &i.Verb, - &i.CatchVerb, &i.Request, - &i.RemainingAttempts, + &i.Response, &i.Error, + &i.RemainingAttempts, &i.Backoff, &i.MaxBackoff, + &i.CatchVerb, + &i.Catching, &i.ParentRequestKey, &i.TraceContext, - &i.Catching, ); err != nil { return nil, err }