apalis-dev / apalis-dev/apalis-postgres

[Bug]: AbortError is ignored — calculate_status has the abort branch commented out

Đang mở
#105 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Rust
Star
9
Fork
13
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### What happened?

apalis-postgres 1.0.0-rc.8 with apalis 1.0.0-rc.9.

In src/ack.rs the abort branch is commented out:

Err(e) => match &e {
// Error::Abort(_) => State::Killed,
_ if parts.ctx.max_attempts() as usize <= parts.attempt.current() => Status::Killed,
_ => Status::Failed,
},

Every Err becomes Status::Failed and the task is refetched until max_attempts (5 by default). There is no way to tell this backend a task must not be retried.

The two retry layers also disagree. apalis-core's BackoffRetryPolicy::retry does honour it:

Err(err) if (err as &dyn Any).downcast_ref::().is_some() => None,

The in-process tower retry stops correctly, then the storage layer refetches the task anyway. RetryPolicy::retry_if has the same problem: the predicate returns false, no in-process retry happens, and the job still runs 5 times.

Repro: a task fn that always returns Err(AbortError::new(...)) against PostgresStorage. Observe 5 executions and attempts = 5.

This makes non-idempotent tasks unsafe — anything with an external side effect gets repeated 5 times even when the failure is known to be permanent.

### Expected behavior

Returning AbortError from a task fn settles the task as Killed after one attempt, with no refetch.

### Steps to reproduce

1. Build a worker on PostgresStorage with a task fn that always returns
Err(AbortError::new("permanent")).
2. Push one task and run the worker.
3. The task executes 5 times instead of once. The row ends at attempts = 5,
and every intermediate ack wrote Status::Failed instead of Killed.

Same result with RetryPolicy::retries(n).retry_if(|_| false) — the predicate
returns false, so the tower layer never retries, but the storage layer refetches
the task anyway.

### Minimal code example

```rust

```

### Version

1.0.0-rc.x

### Environment

- OS: Fedora Linux 44 (Workstation Edition)
- Rust version: 1.97.1
- Cargo version: 1.97.1

### Relevant log output

```shell

```

### Additional context

_No response_

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Start in src/ack.rs at calculate_status and then read the storage retry path alongside BackoffRetryPolicy::retry and RetryPolicy::retry_if. Run the described PostgresStorage reproduction with a task returning AbortError and verify that it executes once, is acknowledged as Killed, and is not refetched.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
postgres, rust
Lĩnh vực
backend, databases
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
64/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.