-
-
Notifications
You must be signed in to change notification settings - Fork 169
fix: manifest duplication #1749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -341,6 +341,17 @@ pub async fn migrate_stream_metadata( | |||||||||||||||||||||||||||||
| schema: &Bytes, | ||||||||||||||||||||||||||||||
| tenant_id: &Option<String>, | ||||||||||||||||||||||||||||||
| ) -> anyhow::Result<Value> { | ||||||||||||||||||||||||||||||
| // Repair, not a version step: snapshots written before the manifest ownership fix can | ||||||||||||||||||||||||||||||
| // hold duplicate entries regardless of their metadata version, so this runs on every | ||||||||||||||||||||||||||||||
| // load and is a no-op once there is nothing left to collapse. | ||||||||||||||||||||||||||||||
| let duplicates_removed = | ||||||||||||||||||||||||||||||
| stream_metadata_migration::dedup_manifest_list(&mut stream_metadata_value); | ||||||||||||||||||||||||||||||
| if duplicates_removed > 0 { | ||||||||||||||||||||||||||||||
| warn!( | ||||||||||||||||||||||||||||||
| "Removed {duplicates_removed} duplicate manifest entries from snapshot of stream {stream}" | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| let version = stream_metadata_value | ||||||||||||||||||||||||||||||
| .as_object() | ||||||||||||||||||||||||||||||
| .and_then(|meta| meta.get("version")) | ||||||||||||||||||||||||||||||
|
|
@@ -432,7 +443,16 @@ pub async fn migrate_stream_metadata( | |||||||||||||||||||||||||||||
| .await?; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| _ => { | ||||||||||||||||||||||||||||||
| // If the version is not recognized, we assume it's already in the latest format | ||||||||||||||||||||||||||||||
| // If the version is not recognized, we assume it's already in the latest format. | ||||||||||||||||||||||||||||||
| // The snapshot repair above still needs persisting when it changed anything. | ||||||||||||||||||||||||||||||
| if duplicates_removed > 0 { | ||||||||||||||||||||||||||||||
| let stream_json: ObjectStoreFormat = | ||||||||||||||||||||||||||||||
| serde_json::from_value(stream_metadata_value.clone())?; | ||||||||||||||||||||||||||||||
| PARSEABLE | ||||||||||||||||||||||||||||||
| .metastore | ||||||||||||||||||||||||||||||
| .put_stream_json(&stream_json, stream, tenant_id) | ||||||||||||||||||||||||||||||
| .await?; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+446
to
+455
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Persisting an unrecognized version through This branch handles versions the binary does not know, which includes a The repair is idempotent and already applied in memory, so persisting here is optional. Either skip the write for unknown versions, or write the repaired 🐛 Proposed change _ => {
- // If the version is not recognized, we assume it's already in the latest format.
- // The snapshot repair above still needs persisting when it changed anything.
- if duplicates_removed > 0 {
- let stream_json: ObjectStoreFormat =
- serde_json::from_value(stream_metadata_value.clone())?;
- PARSEABLE
- .metastore
- .put_stream_json(&stream_json, stream, tenant_id)
- .await?;
- }
+ // The version is not recognized, so the document may come from a newer build.
+ // A typed round trip would drop fields this build does not know, and the repair
+ // is idempotent, so the in-memory result is returned without persisting.
return Ok(stream_metadata_value);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| return Ok(stream_metadata_value); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Scan result depends on directory order when several metadata files exist.
The loop returns the first parsable candidate.
read_dirorder is not defined. If staging holds more than one{node_type}.{id}.jsonfile, for example after an earlier run wrote a different id, the resolved node identity can change between restarts. That defeats the stable-identity goal of this PR and can re-introduce manifest duplication.Consider collecting candidates and selecting deterministically, for example by sorted file name, or log a warning when more than one valid candidate is present.
🤖 Prompt for AI Agents