deleteAllDurableObjects() leaves storage of objects aborted by abortAllDurableObjects()
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
- 54/100
Hướng nghiên cứu
Start with ActorNamespace::delete_all in src/workerd/server/server/actor.rs, then inspect actor_storage_delete_all() in worker-factory-actor.c++ and the existing test_delete_all_durable_objects in unsafe-module-test.js. Reproduce the sequence in the issue: create object storage, abort all objects, then delete all. Done means a fresh object has clean storage after that sequence, with a regression test covering it.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
deleteAllDurableObjects() from workerd:unsafe does not delete the storage of a Durable Object that is not live at the time of the call. After abortAllDurableObjects(), no object is live, so a following deleteAllDurableObjects() deletes nothing and the next request to an object reopens its old SQLite file.
This surfaced as cloudflare/workers-sdk#16510: reset() from cloudflare:test (@cloudflare/vitest-plugin) is a direct call to deleteAllDurableObjects(), and miniflare runs each local D1 database as a Durable Object in a namespace without preventEviction, so a reset() right after abortAllDurableObjects() leaves D1 as it was.
Where
ActorNamespace::delete_all in src/workerd/server/server/actor.rs (same code in v1.20261023.1, v1.20261027.1 and main):
for container in self.actors.borrow().values() {
container.reset_storage();
}
self.abort_all(reason);
match self.storage.get() {
Some(storage) => Ok(ffi::actor_storage_delete_all(storage)?),
None => Ok(()),
}
reset_storage() runs only for containers in self.actors. abort_all() empties that map (std::mem::take), and actor_storage_delete_all() in worker-factory-actor.c++ only calls alarmScheduler->deleteAll(). So storage of any object that is not in the map (aborted earlier) is left on disk. The C++ server in v1.20260918.1 had the same shape in ActorNamespace::deleteAll (server.c++): resetStorage() for each entry of actors, then abortAll(), then the alarm scheduler.
unsafe.h describes deleteAllDurableObjects() as "Like abortAllDurableObjects(), but also deletes storage and cancels alarms so DOs restart with clean state", and test_delete_all_durable_objects in unsafe-module-test.js only covers an object that is live when the delete runs.
Repro
With @cloudflare/vitest-plugin 1.4.8 (miniflare 5.20261023.0-beta, workerd 1.20261023.1), vitest 4.1.11, any Worker with one D1 binding DB (the project in cloudflare/workers-sdk#16510):
import { env } from "cloudflare:workers";
import { abortAllDurableObjects, reset } from "cloudflare:test";
import { expect, test } from "vitest";
const db = (env as unknown as { DB: D1Database }).DB;
async function tables(): Promise<string[]> {
const { results } = await db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE '!_cf!_%' ESCAPE '!'").all<{ name: string }>();
return results.map(row => row.name);
}
test("reset() right after abortAllDurableObjects() leaves D1 as it was", async () => {
await db.exec("CREATE TABLE a (x INTEGER)");
await abortAllDurableObjects();
await reset();
const afterFirst = await tables();
await reset();
const afterSecond = await tables();
console.log(JSON.stringify({ afterFirst, afterSecond }));
expect(afterFirst).toEqual([]);
});
Output: {"afterFirst":["a"],"afterSecond":[]}. The read between the two resets brings the D1 object back into the map, so the second reset deletes it. No query needs to be in flight at the abort.
Possible fix
In delete_all, also delete the on-disk SQLite files (and their -wal/-shm and facet files) of objects in the namespace directory that are not live, after the live ones are reset and aborted. A test in unsafe-module-test.js: write to an object, abortAllDurableObjects(), deleteAllDurableObjects(), then expect the value to be gone on a fresh stub. I have not built workerd, so this is a proposal, not a tested patch.
- Ngôn ngữ chính
- C++
- Star
- 9.3k
- Fork
- 845
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 558
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không 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 cloudflare/workerd
-
Build fails on macOS 27: dyld refuses stripped Rust proc-macros (mis-aligned LINKEDIT string pool)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
cloudflare/workerd#8963 ·
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 72/100
cloudflare/workerd#8807 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
D1 export: `quote()` in d1.js turns a literal `\n` into a newline when the value also has a real newlineCó thể đã có người làm @Jeremiah-D đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
cloudflare/workerd#8678 ·
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 78/100
cloudflare/workerd#8575 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix(types): ForwardableEmailMessage omits the documented canBeForwarded propertyCó thể đã có người làm @itsrayeedscodespace đã nhận 19 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
cloudflare/workerd#8290 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của cloudflare/workerd
Issue tương tự
-
Android Bug Core Drape
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
organicmaps/organicmaps#14449 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
comp-codecs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
ClickHouse/ClickHouse#135159 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[raygui] update to 5.0Đang mởcategory:port-update
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 2 ngày
-
difficulty:easy func:python os:windows prio:high type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NatronGitHub/Natron#2029 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Broken mermaid sequence diagrams on "Invocation execution model" doc page (@ in actor names)Đang mởbug 🐞
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 2 ngày