{"record":{"id":"fcbc04dd83d27d9f","repo":"caddyserver/caddy","slug":"failed-to-acquire-storage-lock-v","errorCode":null,"errorMessage":"failed to acquire storage lock: %v","messagePattern":"failed to acquire storage lock: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddytls/distributedstek/distributedstek.go","lineNumber":153,"sourceCode":"\terr := gob.NewEncoder(&buf).Encode(dstek)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"encoding STEK gob: %v\", err)\n\t}\n\terr = s.storage.Store(s.ctx, stekFileName, buf.Bytes())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"storing STEK gob: %v\", err)\n\t}\n\treturn nil\n}\n\n// getSTEK locks and loads the current STEK from storage. If none\n// currently exists, a new STEK is created and persisted. If the\n// current STEK is outdated (NextRotation time is in the past),\n// then it is rotated and persisted. The resulting STEK is returned.\nfunc (s *Provider) getSTEK() (distributedSTEK, error) {\n\terr := s.storage.Lock(s.ctx, stekLockName)\n\tif err != nil {\n\t\treturn distributedSTEK{}, fmt.Errorf(\"failed to acquire storage lock: %v\", err)\n\t}\n\n\t//nolint:errcheck\n\tdefer s.storage.Unlock(s.ctx, stekLockName)\n\n\t// load the current STEKs from storage\n\tdstek, err := s.loadSTEK()\n\tif errors.Is(err, fs.ErrNotExist) {\n\t\t// if there is none, then make some right away\n\t\tdstek, err = s.rotateKeys(dstek)\n\t\tif err != nil {\n\t\t\treturn dstek, fmt.Errorf(\"creating new STEK: %v\", err)\n\t\t}\n\t} else if err != nil {\n\t\t// some other error, that's a problem\n\t\treturn dstek, fmt.Errorf(\"loading STEK: %v\", err)\n\t} else if time.Now().After(dstek.NextRotation) {\n\t\t// if current STEKs are outdated, rotate them","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddytls/distributedstek/distributedstek.go#L135-L171","documentation":"Error \"failed to acquire storage lock: %v\" thrown in caddyserver/caddy.","triggerScenarios":"Thrown at modules/caddytls/distributedstek/distributedstek.go:153 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check storage backend availability and permissions; another process may hold the lock or the storage may be unreachable."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}