influxdata/influxdb · error · ProcessingEngineError
Failed to rename temp directory to target
Error message
Failed to rename temp directory to target
What it means
Thrown in replace_plugin_directory when the async_fs::rename of the staged temp directory to the final plugin directory target fails (the `e` is wrapped with this context). The rename step is the atomic swap of the new plugin set; its failure means the replacement could not complete. The code attempts to roll back by renaming the old dir back and removing the temp dir.
Solutions
- Ensure the temp directory and the plugin target are on the same filesystem/mount (e.g. both under the same volume).
- Remove any leftover target plugin directory from a previously failed replace, then retry.
- Check write permissions on the plugin directory's parent for the server process user.
- Retry the replace operation; the code already attempts rollback (restores old dir, removes temp).
Example fix
// before: temp dir outside the plugins volume
temp in /tmp, target in /var/lib/influxdb3/plugins
// after: same filesystem
let temp_path = plugin_dir.join(".tmp-replace"); Defensive patterns
Strategy: retry
Validate before calling
// same-filesystem check before replace
const sameFs = fs.statSync(tempDir).dev === fs.statSync(path.dirname(targetDir)).dev;
if (!sameFs) throw new Error('temp dir must be on the same filesystem as plugin dir'); Try / catch
try {
await replacePluginDirectory(files);
} catch (e) {
if (String(e).includes('Failed to rename temp directory')) {
fs.rmSync(targetDir, { recursive: true, force: true }); // clear stale target
await replacePluginDirectory(files); // retry once
} else { throw e; }
} Prevention
- Stage temp dirs inside the same volume as the plugin directory.
- Clean up leftover `.tmp`/stale target dirs after failed replaces.
- Ensure the server process user owns the plugin dir's parent.
- Retry replaces; the operation attempts rollback on failure.
When it happens
Trigger: replace_plugin_directory called when the target plugin path already exists as a non-empty directory (rename fails across platforms), the temp and target are on different filesystems/mounts, or the parent directory is not writable.
Common situations: Plugin directory on a Docker volume while temp dir is in container-local storage (EXDEV cross-device link); stale target directory left by a previous failed replace; permission issues after container user changes; Windows target path locked by another process.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- error writing wal file
- Invalid namespace
- Invalid plugin directory name
- Invalid UTF-8 in parent directory path
- io error
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/b17a8fefda711e11.
Report an issue: GitHub.
Appendix: source
Thrown at influxdb3_processing_engine/src/lib.rs:1260
tokio::spawn(async move {
let _ = async_fs::remove_dir_all(temp_clone).await;
});
ProcessingEngineError::PluginError(PluginError::AnyhowError(e))
})?;
}
let rename_result = async_fs::rename(&temp_path, &plugin_path).await;
if let Err(e) = rename_result {
// Rollback: restore old directory if it exists
if old_path.exists() {
let _ = async_fs::rename(&old_path, &plugin_path).await;
}
let _ = async_fs::remove_dir_all(&temp_path).await;
return Err(ProcessingEngineError::PluginError(
PluginError::AnyhowError(
anyhow!(e).context("Failed to rename temp directory to target"),
),
));
}
if old_path.exists() {
async_fs::remove_dir_all(&old_path)
.await
.context("Failed to delete old directory")
.map_err(|e| ProcessingEngineError::PluginError(PluginError::AnyhowError(e)))?;
}
Ok(db_name)
}
}
#[derive(Debug)]
pub struct PluginFileInfo {
pub plugin_name: Arc<str>,View on GitHub (pinned to 06200ef96b)