Skip to content

Commit eba77ac

Browse files
committed
Address CodeRabbit review feedback on #1770, switch MinIO test image to Quay
- clear_deleting() to roll back mark_deleting() when the tombstone write itself fails, so a transient storage error doesn't permanently strand a stream in "deleting" state - reorder delete handlers (standalone + query node) so spawn_stream_deletion runs last, after local/hot-tier cleanup, and make ingestor fan-out and hot-tier cleanup best-effort instead of bailing the request - reject create/update of a tombstoned-but-not-yet-purged stream even when it isn't resident in memory yet (create_update_stream) - treat a repeated LocalFS delete_stream as success when the prefix is already gone, matching S3/Azure/GCS's empty-prefix behavior - restrict the resident-entry reap in sync_all_streams's tombstone check to non-owner nodes, closing a race with the owner's own in-flight tombstone write - fix stale comment on the dedup test module to reflect the real entry()-based atomic guard Also switch the MinIO image in all four docker-compose test files from minio/minio to quay.io/minio/minio (same pinned release tag) -- minio/minio has been pulled from Docker Hub, which was failing CI at the image-pull step before tests even ran.
1 parent c7fc671 commit eba77ac

10 files changed

Lines changed: 107 additions & 29 deletions

‎docker-compose-distributed-test-with-kafka.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030

3131
# minio
3232
minio:
33-
image: minio/minio:RELEASE.2025-02-03T21-03-04Z
33+
image: quay.io/minio/minio:RELEASE.2025-02-03T21-03-04Z
3434
entrypoint:
3535
- sh
3636
- -euc

‎docker-compose-distributed-test.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ networks:
44
services:
55
# minio
66
minio:
7-
image: minio/minio:RELEASE.2025-02-03T21-03-04Z
7+
image: quay.io/minio/minio:RELEASE.2025-02-03T21-03-04Z
88
entrypoint:
99
- sh
1010
- -euc

‎docker-compose-test-with-kafka.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ networks:
33

44
services:
55
minio:
6-
image: minio/minio:RELEASE.2025-02-03T21-03-04Z
6+
image: quay.io/minio/minio:RELEASE.2025-02-03T21-03-04Z
77
entrypoint:
88
- sh
99
- -euc

‎docker-compose-test.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ networks:
33

44
services:
55
minio:
6-
image: minio/minio:RELEASE.2025-02-03T21-03-04Z
6+
image: quay.io/minio/minio:RELEASE.2025-02-03T21-03-04Z
77
entrypoint:
88
- sh
99
- -euc

‎src/handlers/http/logstream.rs‎

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,19 @@ pub async fn delete(
8383
// Durable marker first: if the process crashes anywhere after this
8484
// point, restart-recovery resumes the deletion instead of silently
8585
// leaving the stream half-deleted with no record of it.
86-
objectstore
86+
if let Err(e) = objectstore
8787
.put_object(
8888
&tombstone_path(&stream_name, &tenant_id),
8989
to_bytes(&()),
9090
&tenant_id,
9191
)
92-
.await?;
92+
.await
93+
{
94+
// Nothing durable happened -- undo the in-memory flag so the stream
95+
// isn't left permanently blocked by a transient write failure.
96+
stream.clear_deleting();
97+
return Err(e.into());
98+
}
9399

94100
// Best-effort: makes the stream vanish from listings almost
95101
// immediately. Not fatal if it fails -- is_deleting()/is_tombstoned()
@@ -104,12 +110,6 @@ pub async fn delete(
104110
);
105111
}
106112

107-
// Scheduled immediately once the stream is durably tombstoned and
108-
// flagged locally, before any of the remaining best-effort steps --
109-
// none of them are allowed to leave the deletion itself unscheduled if
110-
// they fail.
111-
spawn_stream_deletion(stream_name.clone(), tenant_id.clone());
112-
113113
// Delete from staging
114114
if let Err(err) = fs::remove_dir_all(&stream.data_path) {
115115
warn!(
@@ -119,14 +119,24 @@ pub async fn delete(
119119
)
120120
}
121121

122+
// Best-effort: the tombstone is already durable and the stream is
123+
// already flagged, so a hot-tier cleanup failure must not turn an
124+
// already-accepted deletion into an error response.
122125
if let Some(hot_tier_manager) = GLOBAL_HOTTIER.get()
123126
&& hot_tier_manager.check_stream_hot_tier_exists(&stream_name, &tenant_id)
124-
{
125-
hot_tier_manager
127+
&& let Err(e) = hot_tier_manager
126128
.delete_hot_tier(&stream_name, &tenant_id)
127-
.await?;
129+
.await
130+
{
131+
warn!("failed to delete hot tier for stream {stream_name}: {e}");
128132
}
129133

134+
// Scheduled only once every other cleanup step above has run, so the
135+
// background job (which clears the tombstone on completion) can't race
136+
// ahead of them and let a stream recreated under this name get swept up
137+
// by leftover local/hot-tier cleanup that's still in flight.
138+
spawn_stream_deletion(stream_name.clone(), tenant_id.clone());
139+
130140
Ok((
131141
format!("log stream {stream_name} deletion started"),
132142
StatusCode::ACCEPTED,

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

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,19 @@ pub async fn delete(
9292
// Durable marker first: if the process crashes anywhere after this
9393
// point, restart-recovery resumes the deletion instead of silently
9494
// leaving the stream half-deleted with no record of it.
95-
objectstore
95+
if let Err(e) = objectstore
9696
.put_object(
9797
&tombstone_path(&stream_name, &tenant_id),
9898
to_bytes(&()),
9999
&tenant_id,
100100
)
101-
.await?;
101+
.await
102+
{
103+
// Nothing durable happened -- undo the in-memory flag so the stream
104+
// isn't left permanently blocked by a transient write failure.
105+
stream.clear_deleting();
106+
return Err(e.into());
107+
}
102108

103109
// Best-effort: makes the stream vanish from listings almost
104110
// immediately, without touching every listing endpoint individually.
@@ -113,14 +119,13 @@ pub async fn delete(
113119
);
114120
}
115121

116-
// Scheduled immediately once the stream is durably tombstoned and
117-
// flagged locally, before any of the remaining best-effort steps --
118-
// none of them are allowed to leave the deletion itself unscheduled if
119-
// they fail.
120-
spawn_stream_deletion(stream_name.clone(), tenant_id.clone());
121-
122+
// Best-effort: the tombstone is already durable and the stream is
123+
// already flagged, so a fan-out failure must not turn an
124+
// already-accepted deletion into an error response -- an ingestor that
125+
// misses this push self-heals via sync_all_streams within one sync
126+
// interval regardless.
122127
let fanout_stream_name = stream_name.clone();
123-
cluster::for_each_live_node(&tenant_id, move |node| {
128+
if let Err(e) = cluster::for_each_live_node(&tenant_id, move |node| {
124129
let url = format!(
125130
"{}{}/logstream/{}/sync",
126131
node.domain_name,
@@ -129,7 +134,10 @@ pub async fn delete(
129134
);
130135
async move { cluster::send_stream_delete_request(&url, node).await }
131136
})
132-
.await?;
137+
.await
138+
{
139+
warn!("failed to notify all ingestors of deletion of {stream_name}: {e}");
140+
}
133141

134142
if let Err(err) = fs::remove_dir_all(&stream.data_path) {
135143
warn!(
@@ -141,12 +149,19 @@ pub async fn delete(
141149

142150
if let Some(hot_tier_manager) = GLOBAL_HOTTIER.get()
143151
&& hot_tier_manager.check_stream_hot_tier_exists(&stream_name, &tenant_id)
144-
{
145-
hot_tier_manager
152+
&& let Err(e) = hot_tier_manager
146153
.delete_hot_tier(&stream_name, &tenant_id)
147-
.await?;
154+
.await
155+
{
156+
warn!("failed to delete hot tier for stream {stream_name}: {e}");
148157
}
149158

159+
// Scheduled only once every other cleanup step above has run, so the
160+
// background job (which clears the tombstone on completion) can't race
161+
// ahead of them and let a stream recreated under this name get swept up
162+
// by leftover fan-out/local/hot-tier cleanup that's still in flight.
163+
spawn_stream_deletion(stream_name.clone(), tenant_id.clone());
164+
150165
Ok((
151166
format!("log stream {stream_name} deletion started"),
152167
StatusCode::ACCEPTED,

‎src/parseable/mod.rs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,30 @@ impl Parseable {
810810
});
811811
}
812812

813+
// A tombstoned-but-not-yet-purged stream must be rejected the same
814+
// way even when it isn't resident in memory on this node yet (e.g. a
815+
// query node before restart-recovery has resumed it, or a node that
816+
// never loaded it in the first place). create_stream_and_schema_from_storage
817+
// below already checks this internally and returns Ok(false) for a
818+
// tombstoned stream, but that's indistinguishable from "doesn't
819+
// exist" to its caller -- without this explicit check, the client
820+
// could recreate the name while the background deletion job is
821+
// still sweeping its prefix, and that job would delete the freshly
822+
// created data too.
823+
if !stream_in_memory_dont_update
824+
&& is_tombstoned(
825+
self.storage.get_object_store().as_ref(),
826+
stream_name,
827+
tenant_id,
828+
)
829+
.await?
830+
{
831+
return Err(StreamError::Custom {
832+
msg: format!("Logstream {stream_name} is being deleted, please retry shortly"),
833+
status: StatusCode::CONFLICT,
834+
});
835+
}
836+
813837
// check if stream in storage only if not in memory
814838
// for Parseable OSS, create_update_stream is called only from query node
815839
// for Parseable Enterprise, create_update_stream is called from prism node

‎src/parseable/streams.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,14 @@ impl Stream {
16321632
self.metadata.write().expect(LOCK_EXPECT).deleting = true;
16331633
}
16341634

1635+
/// Undoes a `mark_deleting()` call whose tombstone write then failed.
1636+
/// Safe only because nothing durable was ever created -- unlike
1637+
/// `mark_deleting()`, this is not part of the monotonic contract, and
1638+
/// must never be called once the tombstone actually exists in storage.
1639+
pub fn clear_deleting(&self) {
1640+
self.metadata.write().expect(LOCK_EXPECT).deleting = false;
1641+
}
1642+
16351643
pub fn is_deleting(&self) -> bool {
16361644
self.metadata.read().expect(LOCK_EXPECT).deleting
16371645
}

‎src/storage/localfs.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,15 @@ impl ObjectStorage for LocalFS {
496496
let tenant_str = tenant_id.as_deref().unwrap_or(DEFAULT_TENANT);
497497

498498
let result = fs::remove_dir_all(path).await;
499+
// A retried deletion (e.g. resumed after a crash between the
500+
// directory being removed and the tombstone being cleared) finds
501+
// nothing left to remove -- treat that the same as success, matching
502+
// S3/Azure/GCS, whose prefix delete is already a no-op success when
503+
// the prefix is already empty.
504+
let result = match result {
505+
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(()),
506+
other => other,
507+
};
499508
if result.is_ok() {
500509
increment_object_store_calls_by_date(
501510
"DELETE",

‎src/storage/object_storage.rs‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,7 @@ pub fn sync_all_streams(joinset: &mut JoinSet<Result<(), ObjectStorageError>>) {
14411441
spawn_stream_deletion(stream_name, tenant_id);
14421442
}
14431443
}
1444-
Ok(false) => {
1444+
Ok(false) if !is_deletion_owner => {
14451445
// Deletion already finished elsewhere and
14461446
// the tombstone is gone, but this node's
14471447
// resident entry was never dropped -- e.g.
@@ -1452,6 +1452,18 @@ pub fn sync_all_streams(joinset: &mut JoinSet<Result<(), ObjectStorageError>>) {
14521452
// deleting=true state.
14531453
PARSEABLE.streams.delete(&stream_name, &tenant_id);
14541454
}
1455+
Ok(false) => {
1456+
// On the owning node, an absent tombstone
1457+
// can also just mean this delete hasn't
1458+
// written it yet (mark_deleting() runs
1459+
// first, with the tombstone write still
1460+
// in flight). Reaping here would race
1461+
// that window and let a concurrent reload
1462+
// resurrect the stream mid-deletion --
1463+
// the owner's own spawn_stream_deletion
1464+
// job removes this entry once the actual
1465+
// delete (and tombstone clear) completes.
1466+
}
14551467
Err(e) => error!(
14561468
"failed to check tombstone status for {stream_name}: {e}"
14571469
),

0 commit comments

Comments
 (0)