{"record":{"id":"36b2b7a33fe2a908","repo":"spacedriveapp/spacedrive","slug":"entry-not-found-after-creation","errorCode":null,"errorMessage":"Entry not found after creation","messagePattern":"Entry not found after creation","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/src/ops/indexing/change_detection/persistent.rs","lineNumber":255,"sourceCode":"\t\t}\n\n\t\tlet entry_id = DatabaseStorage::create_entry(\n\t\t\t&mut state,\n\t\t\t&self.db,\n\t\t\tlibrary.as_deref(),\n\t\t\tmetadata,\n\t\t\tself.volume_id,\n\t\t\tparent_path,\n\t\t)\n\t\t.await\n\t\t.map_err(|e| anyhow::anyhow!(\"Failed to create entry: {}\", e))?;\n\n\t\tself.entry_id_cache.insert(metadata.path.clone(), entry_id);\n\n\t\tlet entry = entities::entry::Entity::find_by_id(entry_id)\n\t\t\t.one(&self.db)\n\t\t\t.await?\n\t\t\t.ok_or_else(|| anyhow::anyhow!(\"Entry not found after creation\"))?;\n\n\t\tOk(EntryRef {\n\t\t\tid: entry.id,\n\t\t\tuuid: entry.uuid,\n\t\t\tpath: metadata.path.clone(),\n\t\t\tkind: metadata.kind,\n\t\t})\n\t}\n\n\tasync fn update(&mut self, entry: &EntryRef, metadata: &DirEntry) -> Result<()> {\n\t\tuse crate::ops::indexing::database_storage::DatabaseStorage;\n\n\t\tDatabaseStorage::update_entry(&self.db, entry.id, metadata)\n\t\t\t.await\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to update entry: {}\", e))?;\n\n\t\tOk(())\n\t}","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/core/src/ops/indexing/change_detection/persistent.rs#L237-L273","documentation":"DatabaseStorage::create_entry returned an entry_id, but the immediate find_by_id for that same id finds no row. Since the insert succeeded on self.db, the miss implies the insert was rolled back, the row was deleted within milliseconds, or self.db points at a different connection/transaction than the one that wrote. It is a self-inconsistency check after creation.","triggerScenarios":"Concurrent delete of the just-created entry; the create ran inside a transaction that aborted after returning the id; connection pooling routing the follow-up SELECT to a replica or a different DB file.","commonSituations":"Duplicate watcher events where one worker creates and another deletes immediately; SQLite WAL setups with a stale read connection; nested transaction rollback paths.","solutions":["Have DatabaseStorage::create_entry return the created row (or construct EntryRef directly from the insert) instead of re-querying","Check whether a concurrent delete/reindex job is running on the same library","Verify all queries in this adapter use the same connection (self.db) as the insert"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let entry = match entities::entry::Entity::find_by_id(entry_id).one(&self.db).await? {\n    Some(e) => e,\n    None => {\n        tracing::warn!(%entry_id, \"entry vanished immediately after creation; retrying once\");\n        return Err(anyhow::anyhow!(\"Entry not found after creation\"));\n    }\n};","preventionTips":["Return the created row from create_entry instead of re-querying it","Guarantee the adapter uses one connection for create and subsequent reads","Check for concurrent delete workers on the same library when this recurs"],"tags":["indexing","database","race-condition","create","change-detection"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}