risingwavelabs/risingwave · critical

failed to create

Error message

failed to create `{}`: {}

What it means

init_risingwave_logger opens the query-log file with OpenOptions (create+write+truncate) and panics on failure, reporting the path and OS error. This happens after directory creation succeeds, so failures here are about writing/opening the log file itself.

Solutions

  1. Ensure the directory is writable by the process user (chmod/chown) and the path points to a file, not a directory.
  2. Free disk space if ENOSPC is reported.
  3. Remove a stale read-only log file so it can be recreated.
  4. Unset RW_QUERY_LOG_PATH to disable file-based query logging.

Example fix

// before: file owned by root, mode 0444
-r--r--r-- query.log
// after
sudo chown risingwave:risingwave query.log && chmod 0644 query.log
Defensive patterns

Strategy: validation

Validate before calling

use std::path::Path;
let p = std::env::var("RW_QUERY_LOG_PATH").unwrap_or_default();
let dir = Path::new(&p);
assert!(dir.is_dir(), "RW_QUERY_LOG_PATH must be an existing writable directory");
assert!(dir.permissions().readonly() == false, "RW_QUERY_LOG_PATH is read-only");

Prevention

When it happens

Trigger: The resolved log file path cannot be opened: no write permission on the file or directory, disk full (io error), the path is a directory, or a name/length issue on the target filesystem.

Common situations: File exists but is owned by another user with read-only mode; path component is a directory; ENOSPC on full disks; SELinux/AppArmor blocking file creation in that directory.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/5f8ec00fc2dbfeb1. Report an issue: GitHub.

Appendix: source

Thrown at src/utils/runtime/src/logger.rs:411

                fields: R,
            ) -> std::fmt::Result {
                self.0.format_fields(writer, fields)
            }
        }

        for (file_name, target, is_slow) in [
            ("query.log", PGWIRE_QUERY_LOG, false),
            ("slow_query.log", PGWIRE_SLOW_QUERY_LOG, true),
        ] {
            let path = query_log_path.join(file_name);

            let file = std::fs::OpenOptions::new()
                .create(true)
                .write(true)
                .truncate(true)
                .open(&path)
                .unwrap_or_else(|e| {
                    panic!("failed to create `{}`: {}", path.display(), e.as_report(),)
                });

            let layer = tracing_subscriber::fmt::layer()
                .with_ansi(false)
                .with_level(false)
                .with_file(false)
                .with_target(false)
                .with_timer(default_timer.clone())
                .with_thread_names(true)
                .with_thread_ids(true)
                .with_writer(file);

            let layer = match is_slow {
                true => layer.fmt_fields(FmtFields::<true>::default()).boxed(),
                false => layer.fmt_fields(FmtFields::<false>::default()).boxed(),
            };

            let layer = layer.with_filter(

View on GitHub (pinned to 6469eb736d)