{"record":{"id":"8c082efe09fd12f3","repo":"hashicorp/nomad","slug":"locks-w","errorCode":null,"errorMessage":"locks: %w","messagePattern":"locks: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/locks.go","lineNumber":343,"sourceCode":"\t\t\t\t}\n\t\t\t}()\n\n\t\t\t// Maintain lease is a blocking function, it will return if there is\n\t\t\t// an error maintaining the lease or the protected function returned.\n\t\t\terr = ll.maintainLease(funcCtx)\n\t\t\tif err != nil && !errors.Is(err, ErrLockConflict) {\n\t\t\t\terrChannel <- fmt.Errorf(\"error renewing the lease: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\twaitTicker.Stop()\n\t\twaitTicker = time.NewTicker(ll.waitPeriod)\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil\n\n\t\tcase err := <-errChannel:\n\t\t\treturn fmt.Errorf(\"locks: %w\", err)\n\n\t\tcase <-waitTicker.C:\n\t\t}\n\t}\n}\n\nfunc (ll *LockLeaser) maintainLease(ctx context.Context) error {\n\trenewTicker := time.NewTicker(ll.renewalPeriod)\n\tdefer renewTicker.Stop()\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil\n\n\t\tcase <-renewTicker.C:\n\t\t\terr := ll.locker.Renew(ctx)\n\t\t\tif err != nil {\n\t\t\t\treturn err","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/api/locks.go#L325-L361","documentation":"In LockLeaser.start's monitor loop, any error surfaced from ll.maintainLease (renewal, session loss, or lock invalidation other than ErrLockConflict, which exits silently) is wrapped with this prefix and returned from the lock monitoring loop, ending the caller's held lease. It means the Consul lock lease could no longer be maintained.","triggerScenarios":"Thrown at api/locks.go:343 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped inner error to determine whether the Consul session expired, the lock was contended, or the Consul connection failed","Verify connectivity between the client and the Consul servers","Re-acquire the lock by calling Start again once Consul is reachable","Check Consul server logs for session invalidation around the failure time"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}