Offline action reports success after leadership loss before outbox admission
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 50/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- distributed-systems, documentation, testing-qa
Hướng nghiên cứu
Start with packages/offline-transactions/tests/leadership-replay.property.test.ts and run the provided Vitest probe command. Trace persistTransaction() through its leadership guard and resolveTransaction(), then compare the public transaction settlement contract with the offline admission behavior. Extend coverage for selection-to-admission leadership loss, update docs/contributing/oracle-coverage.md and the guide from #1938, and verify the no-success-without-durability case.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug
An offline action can report success after it loses leadership but before its mutation reaches the outbox. The mutation is neither durable nor sent to the server. In the controlled reproduction below, the Collection row is also absent after the success signal.
This was found while reviewing the documentation in #1938. The production code is unchanged by that docs PR. It is related to the offline admission policy tracked in #1659, but this is a concrete current-path failure.
Reproduction
On commit 9bf2444072c3c4aefebd072efd08f14be99afb0a, save this as packages/offline-transactions/tests/leadership-admission-review-probe.test.ts:
import { expect, it } from 'vitest'
import { createTestOfflineEnvironment } from './harness'
it('does not report success when leadership is lost before outbox admission', async () => {
const env = createTestOfflineEnvironment()
await env.waitForLeader()
const action = env.executor.createOfflineAction({
mutationFnName: env.mutationFnName,
onMutate: (item: {
id: string
value: string
completed: boolean
updatedAt: Date
}) => {
env.collection.insert(item)
env.leader.setLeader(false)
},
})
try {
const transaction = action({
id: 'handoff-item',
value: 'Buy milk',
completed: false,
updatedAt: new Date(),
})
const outcome = await transaction.isPersisted.promise.then(
() => 'fulfilled',
() => 'rejected',
)
const durable = await env.executor.peekOutbox()
expect(env.executor.isOfflineEnabled).toBe(false)
expect(env.collection.get('handoff-item')).toBeUndefined()
expect([outcome, durable.length, env.mutationCalls.length]).not.toEqual([
'fulfilled',
0,
0,
])
} finally {
env.executor.dispose()
await env.collection.cleanup()
}
})
Run pnpm --filter @tanstack/offline-transactions exec vitest run tests/leadership-admission-review-probe.test.ts. The test fails with:
AssertionError: expected [ 'fulfilled', +0, +0 ] to not deeply equal [ 'fulfilled', +0, +0 ]
The leadership change happens synchronously in onMutate, after createOfflineAction() has selected its offline wrapper. persistTransaction() reaches its guard after an await and calls resolveTransaction() when leadership is gone. It never calls outbox.add() or the configured mutationFn. The completion promise then fulfills.
Expected behavior and coverage
An action must not report success when no durable record exists and no server mutation ran. The admission policy needs a decision: either reject and roll back the action at this boundary, or hand it off durably to the next leader. The first option appears smaller, but both should be checked against the public transaction settlement contract.
packages/offline-transactions/tests/leadership-replay.property.test.ts is the primary leadership oracle. It covers already durable replay but does not generate the selection-to-admission leadership loss. Extend its grammar and public observations to cover that transition and nearby legal histories; prove the witness fails on current code and passes with the repair. Record the resulting scope in docs/contributing/oracle-coverage.md.
The guide in #1938 says actions use the online-only path when offline mode is disabled. That describes actions that start while it is disabled, but not this action, which selected the offline path before leadership changed. Update the guide alongside the behavior decision.
- Ngôn ngữ chính
- TypeScript
- Star
- 3.9k
- Fork
- 267
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 104
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/db
-
Index suggestion for collection size is gated on autoIndex, so it only fires where it is redundantĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Mend: dependency security vulnerability untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
opensearch-project/security-dashboards-plugin#2545 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: Dream TR SDĐang mởcheck:passed streams:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
doctor integrity sample scans soft-deleted pages on Postgres (batch path has no deleted_at filter)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
SocialGouv/egapro#4672 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
area:agents area:tui bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
anthropics/claude-code#98358 ·
Maintainer thường phản hồi trong vòng 1 ngày