{"record":{"id":"756b7159be7d1642","repo":"hyperledger/fabric","slug":"initialization-of-chaincode-store-failed-s","errorCode":null,"errorMessage":"Initialization of chaincode store failed: %s","messagePattern":"Initialization of chaincode store failed: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/chaincode/persistence/persistence.go","lineNumber":152,"sourceCode":"\t\tPath:       path,\n\t\tReadWriter: &FilesystemIO{},\n\t}\n\tstore.Initialize()\n\treturn store\n}\n\n// Initialize checks for the existence of the _lifecycle chaincodes\n// directory and creates it if it has not yet been created.\nfunc (s *Store) Initialize() {\n\tvar (\n\t\texists bool\n\t\terr    error\n\t)\n\tif exists, err = s.ReadWriter.Exists(s.Path); exists {\n\t\treturn\n\t}\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Initialization of chaincode store failed: %s\", err))\n\t}\n\tif err = s.ReadWriter.MakeDir(s.Path, 0o750); err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not create _lifecycle chaincodes install path: %s\", err))\n\t}\n}\n\n// Save persists chaincode install package bytes. It returns\n// the hash of the chaincode install package\nfunc (s *Store) Save(label string, ccInstallPkg []byte) (string, error) {\n\tpackageID := PackageID(label, ccInstallPkg)\n\n\tccInstallPkgFileName := CCFileName(packageID)\n\tccInstallPkgFilePath := filepath.Join(s.Path, ccInstallPkgFileName)\n\n\tif exists, _ := s.ReadWriter.Exists(ccInstallPkgFilePath); exists {\n\t\t// chaincode install package was already installed\n\t\treturn packageID, nil\n\t}","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/persistence/persistence.go#L134-L170","documentation":"Store.Initialize ensures the chaincode install directory exists on first use: it calls Exists(s.Path) and, if stat failed with a real error (not a simple 'not found'), panics with this message since the store cannot determine or create its state.","triggerScenarios":"NewStore -> Initialize when ReadWriter.Exists(s.Path) returns a non-nil, non-NotExist error — e.g. EACCES on a parent directory, an I/O error on a failing mount, or a symlink loop along the path.","commonSituations":"Peer start with mis-owned data directories (root-owned /var/hyperledger); damaged or unavailable storage volumes; running the peer in a container where the mounted volume is read-only or misconfigured.","solutions":["Fix ownership/permissions so the peer user can stat the path (e.g. `chown -R peer:peer /var/hyperledger/production`)","Verify the storage volume is mounted, writable, and healthy before starting the peer","Inspect the error text embedded in the panic (it contains the wrapped cause) for the exact OS-level problem","If the path is on a failing device, restore from backup or re-provision storage and restart the peer"],"exampleFix":"// before: starting peer with root-owned data dir\n// panic: Initialization of chaincode store failed: stat ...: permission denied\n\n// after\nchown -R peer:peer /var/hyperledger/production\n# then restart the peer","handlingStrategy":"try-catch","validationCode":"func checkStorePathUsable(p string) error {\n    if _, err := os.Stat(p); err != nil && !os.IsNotExist(err) {\n        return fmt.Errorf(\"store path unusable: %w\", err)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        if s, ok := r.(string); ok && strings.HasPrefix(s, \"Initialization of chaincode store failed\") {\n            log.Fatalf(\"fix store path permissions/mount before starting: %s\", s)\n        }\n        panic(r)\n    }\n}()\nstore, err := persistence.NewStore(path, &persistence.FilesystemIO{})","preventionTips":["Run the peer as a dedicated user that owns the entire production data tree","Verify volume mounts and permissions in the peer's startup/health checks before lifecycle operations","Capture the panic message's embedded cause for the exact errno and fix storage accordingly"],"tags":["filesystem","initialization","panic","permissions"],"backgroundTag":"permission-denied","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}