Skip to content

Commit a3037b5

Browse files
committed
Flip the deleting flag before the tombstone write, not after
check_or_load_stream's resident-stream fast path doesn't itself check is_tombstoned (flagged in CodeRabbit's review of #1768), so a concurrent request on the same node could slip through in the window between the tombstone becoming durable and mark_deleting() actually running. Moving mark_deleting() before the tombstone write, with no await point in between, closes that window entirely for the initiating node. Cross-node propagation is still bounded by the existing fan-out push and self-heal, not synchronous -- that's an accepted, already-documented limitation of this design, not something this reorder attempts to fix.
1 parent eeb367f commit a3037b5

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎src/handlers/http/logstream.rs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ pub async fn delete(
7272
// deletion.
7373
let stream = PARSEABLE.get_stream(&stream_name, &tenant_id)?;
7474

75+
// Flip the in-memory guard before any `.await` point: check_or_load_stream's
76+
// resident-stream fast path doesn't itself consult is_tombstoned, so a
77+
// concurrent request on this node could otherwise slip through in the
78+
// window between the tombstone becoming durable and this flag being set.
79+
stream.mark_deleting();
80+
7581
let objectstore = PARSEABLE.storage.get_object_store();
7682

7783
// Durable marker first: if the process crashes anywhere after this
@@ -98,7 +104,6 @@ pub async fn delete(
98104
);
99105
}
100106

101-
stream.mark_deleting();
102107
// Scheduled immediately once the stream is durably tombstoned and
103108
// flagged locally, before any of the remaining best-effort steps --
104109
// none of them are allowed to leave the deletion itself unscheduled if

‎src/handlers/http/modal/query/querier_logstream.rs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ pub async fn delete(
8181
// deletion.
8282
let stream = PARSEABLE.get_stream(&stream_name, &tenant_id)?;
8383

84+
// Flip the in-memory guard before any `.await` point: check_or_load_stream's
85+
// resident-stream fast path doesn't itself consult is_tombstoned, so a
86+
// concurrent request on this node could otherwise slip through in the
87+
// window between the tombstone becoming durable and this flag being set.
88+
stream.mark_deleting();
89+
8490
let objectstore = PARSEABLE.storage.get_object_store();
8591

8692
// Durable marker first: if the process crashes anywhere after this
@@ -107,7 +113,6 @@ pub async fn delete(
107113
);
108114
}
109115

110-
stream.mark_deleting();
111116
// Scheduled immediately once the stream is durably tombstoned and
112117
// flagged locally, before any of the remaining best-effort steps --
113118
// none of them are allowed to leave the deletion itself unscheduled if

0 commit comments

Comments
 (0)