{"record":{"id":"22020ea32c092c6f","repo":"hashicorp/terraform","slug":"lock-id-mismatch-v-v","errorCode":null,"errorMessage":"lock id mismatch, %v != %v","messagePattern":"lock id mismatch, (.+?) != (.+?)","errorType":"console","errorClass":"statemgr.LockError","httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/cos/client.go","lineNumber":126,"sourceCode":"\terr = c.putObject(c.lockFile, data)\n\tif err != nil {\n\t\treturn \"\", c.lockError(err)\n\t}\n\n\treturn check, nil\n}\n\n// Unlock unlock remote state file\nfunc (c *remoteClient) Unlock(check string) error {\n\tlog.Printf(\"[DEBUG] unlock remote state file %s\", c.lockFile)\n\n\tinfo, err := c.lockInfo()\n\tif err != nil {\n\t\treturn c.lockError(err)\n\t}\n\n\tif info.ID != check {\n\t\treturn c.lockError(fmt.Errorf(\"lock id mismatch, %v != %v\", info.ID, check))\n\t}\n\n\terr = c.deleteObject(c.lockFile)\n\tif err != nil {\n\t\treturn c.lockError(err)\n\t}\n\n\terr = c.cosUnlock(c.bucket, c.lockFile)\n\tif err != nil {\n\t\treturn c.lockError(err)\n\t}\n\n\treturn nil\n}\n\n// lockError returns statemgr.LockError\nfunc (c *remoteClient) lockError(err error) *statemgr.LockError {\n\tlog.Printf(\"[DEBUG] failed to lock or unlock %s: %v\", c.lockFile, err)","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote-state/cos/client.go#L108-L144","documentation":"Raised by remoteClient.Unlock() (cos/client.go:126) when the lock info's stored ID (the md5 checksum of the lock file) does not match the check value supplied to Unlock. You may only release a lock whose ID matches the one returned by your own Lock call.","triggerScenarios":"Unlock(check) reads lockInfo() and finds info.ID != check; e.g. calling force-unlock with the wrong ID, or the lock was replaced by a different holder.","commonSituations":"Using a stale or copied lock ID for force-unlock; the lock was already taken over by another process whose ID differs; checksum mismatch due to a rewritten lock file.","solutions":["Use the exact lock ID reported in the original lock error message.","Run `terraform force-unlock <correct-id>` with the ID shown by terraform.","If no correct ID is known, inspect the lock file object to recover its md5 ID."],"exampleFix":"// before: wrong id\nterraform force-unlock 00000000\n// after: id from the lock error\nterraform force-unlock abc123def456","handlingStrategy":"validation","validationCode":"// Confirm the supplied unlock ID matches the stored lock ID before unlocking\nstored, err := c.lockInfo()\nif err == nil && stored.ID != check {\n    return fmt.Errorf(\"lock id mismatch, %v != %v\", stored.ID, check)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always unlock with the exact ID returned by your Lock call.","Copy lock IDs verbatim from terraform error messages for force-unlock.","Inspect the lock file object to recover its md5 ID if the original is lost."],"tags":["cos","tencentcloud","lock","unlock","id-mismatch","force-unlock"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}