{"action":"created","issue":{"url":"https://api.github.com/repos/mike-marcacci/node-redlock/issues/38","repository_url":"https://api.github.com/repos/mike-marcacci/node-redlock","labels_url":"https://api.github.com/repos/mike-marcacci/node-redlock/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/mike-marcacci/node-redlock/issues/38/comments","events_url":"https://api.github.com/repos/mike-marcacci/node-redlock/issues/38/events","html_url":"https://github.com/mike-marcacci/node-redlock/issues/38","id":294003661,"number":38,"title":"Unable to acquire lock","user":{"login":"krg7880","id":8606515,"avatar_url":"https://avatars0.githubusercontent.com/u/8606515?v=4","gravatar_id":"","url":"https://api.github.com/users/krg7880","html_url":"https://github.com/krg7880","followers_url":"https://api.github.com/users/krg7880/followers","following_url":"https://api.github.com/users/krg7880/following{/other_user}","gists_url":"https://api.github.com/users/krg7880/gists{/gist_id}","starred_url":"https://api.github.com/users/krg7880/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krg7880/subscriptions","organizations_url":"https://api.github.com/users/krg7880/orgs","repos_url":"https://api.github.com/users/krg7880/repos","events_url":"https://api.github.com/users/krg7880/events{/privacy}","received_events_url":"https://api.github.com/users/krg7880/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-02T19:51:39Z","updated_at":"2018-02-05T16:25:32Z","closed_at":null,"author_association":"NONE","body":"**Redis Client**\r\n[ioredis](https://github.com/luin/ioredis)\r\n\r\n**Sample Code**\r\n```\r\nconst test = async () => {\r\n  const Redis = require('ioredis')\r\n  const Redlock = require('redlock')\r\n  const client = new Redis('localhost:6379')\r\n  const redLock = new Redlock([client])\r\n  try {\r\n    await client.setex('foo', 6000, JSON.stringify({ name: 'Bob' }))\r\n    const lock = await redLock.lock('foo', 2000)\r\n  } catch (e) {\r\n    console.log(e)\r\n  }\r\n}\r\n\r\ntest()\r\n```\r\n**Error**\r\n```\r\nLockError: Exceeded 10 attempts to lock the resource \"foo\"\r\n```\r\n\r\nI dug into the code to inspect what was going on and it looks like the [call](https://github.com/mike-marcacci/node-redlock/blob/master/redlock.js#L289) to acquire the lock never returns a response (ie: `OK`) although there were no errors. This means the check to increment [votes](https://github.com/mike-marcacci/node-redlock/blob/master/redlock.js#L317) fails and we never get the lock. Any thoughts on this or am I way off?\r\n"},"comment":{"url":"https://api.github.com/repos/mike-marcacci/node-redlock/issues/comments/363137220","html_url":"https://github.com/mike-marcacci/node-redlock/issues/38#issuecomment-363137220","issue_url":"https://api.github.com/repos/mike-marcacci/node-redlock/issues/38","id":363137220,"user":{"login":"krg7880","id":8606515,"avatar_url":"https://avatars0.githubusercontent.com/u/8606515?v=4","gravatar_id":"","url":"https://api.github.com/users/krg7880","html_url":"https://github.com/krg7880","followers_url":"https://api.github.com/users/krg7880/followers","following_url":"https://api.github.com/users/krg7880/following{/other_user}","gists_url":"https://api.github.com/users/krg7880/gists{/gist_id}","starred_url":"https://api.github.com/users/krg7880/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krg7880/subscriptions","organizations_url":"https://api.github.com/users/krg7880/orgs","repos_url":"https://api.github.com/users/krg7880/repos","events_url":"https://api.github.com/users/krg7880/events{/privacy}","received_events_url":"https://api.github.com/users/krg7880/received_events","type":"User","site_admin":false},"created_at":"2018-02-05T16:25:32Z","updated_at":"2018-02-05T16:25:32Z","author_association":"NONE","body":"@mike-marcacci Thanks for the prompt and detailed follow-up. Yeah, the issue was not providing a unique prefix for the lock key. I was able to get it working this morning by doing just that. With regards to the value of the `TTL` and the Redis commands being utilized (ie: `SETEX`), the values were dummy values I entered while drafting this ticket. At this point, everything seems to be working as expected. Thanks again!"}}
{"actor":{"display_login":"krg7880"}}