-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
When using PostgreSQL as the database backend, piri fails to start with:
creating pdp object store: mkdir /data/piri/pdp/datastore: no such file or directory
Root Cause
The flatfs.create() function uses os.Mkdir() which only creates a single directory level. It fails if the parent directory doesn't exist.
Why it worked with SQLite:
ensureSQLiteDir()is called for SQLite, which usesos.MkdirAll()- SQLite path is
/data/piri/pdp/state/state.db - This inadvertently creates
/data/piri/pdp/as a side effect - Later, PDP store creation at
/data/piri/pdp/datastoresucceeds because parent exists
Why it fails with PostgreSQL:
ensureSQLiteDir()is never called (postgres doesn't need local DB file)/data/piri/pdp/is never created- PDP store creation fails because
os.Mkdir()can't create parent directories
Fix
In pkg/store/objectstore/flatfs/flatfs.go, line 137:
// Before
err := os.Mkdir(path, 0755)
if err != nil && !os.IsExist(err) {
return err
}
// After
err := os.MkdirAll(path, 0755)
if err != nil {
return err
}os.MkdirAll() creates the entire directory tree including parents, and doesn't error if the directory already exists.
Affected Code
pkg/store/objectstore/flatfs/flatfs.go-create()function- Hidden dependency on SQLite initialization order
Testing
Discovered via smelt integration tests with --profile piri-postgres. All existing flatfs unit tests pass with the fix.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Inbox