{"action":"created","issue":{"url":"https://api.github.com/repos/antirez/redis/issues/2479","labels_url":"https://api.github.com/repos/antirez/redis/issues/2479/labels{/name}","comments_url":"https://api.github.com/repos/antirez/redis/issues/2479/comments","events_url":"https://api.github.com/repos/antirez/redis/issues/2479/events","html_url":"https://github.com/antirez/redis/issues/2479","id":64751138,"number":2479,"title":"Error registering fd event for event for the new client:No such file or direcory","user":{"login":"YongMan","id":3875656,"avatar_url":"https://avatars.githubusercontent.com/u/3875656?v=3","gravatar_id":"","url":"https://api.github.com/users/YongMan","html_url":"https://github.com/YongMan","followers_url":"https://api.github.com/users/YongMan/followers","following_url":"https://api.github.com/users/YongMan/following{/other_user}","gists_url":"https://api.github.com/users/YongMan/gists{/gist_id}","starred_url":"https://api.github.com/users/YongMan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YongMan/subscriptions","organizations_url":"https://api.github.com/users/YongMan/orgs","repos_url":"https://api.github.com/users/YongMan/repos","events_url":"https://api.github.com/users/YongMan/events{/privacy}","received_events_url":"https://api.github.com/users/YongMan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/antirez/redis/labels/critical%20bug","name":"critical bug","color":"e10c02"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-03-27T12:13:42Z","updated_at":"2015-12-04T02:22:21Z","closed_at":null,"body":"`Redis:2.8.9`\r\n`Linux Kernel:2.6.32`\r\n\r\nThe redis.log shows that an error occured to the accept fd, and the log always flush the same line and the client can not connect to the server. The log screenshot as shows:\r\n![2015-05-15 9 32 34](https://cloud.githubusercontent.com/assets/3875656/7645313/c115ffee-fae5-11e4-9118-de0afee0d9c3.png)\r\n\r\n\r\nThe strace output is as follows:\r\n```\r\nepoll_ctl(3, EPOLL_CTL_MOD, 31, {EPOLLIN, {u32=31, u64=31}}) = 0\r\nepoll_wait(3, {{EPOLLIN, {u32=4, u64=4}}}, 204928, 19) = 1\r\naccept(4, {sa_family=AF_INET, sin_port=htons(50585), sin_addr=inet_addr(\"10.52.88.57\")}, [11080262466804908048]) = 70\r\nfcntl(70, F_GETFL)                      = 0x2 (flags O_RDWR)\r\nfcntl(70, F_SETFL, O_RDWR|O_NONBLOCK)   = 0\r\nsetsockopt(70, SOL_TCP, TCP_NODELAY, [1], 4) = 0\r\nepoll_ctl(3, EPOLL_CTL_MOD, 70, {EPOLLIN, {u32=70, u64=70}}) = -1 ENOENT (No such file or directory)\r\nclose(70)                               = 0\r\nopen(\"./log/redis.log\", O_WRONLY|O_APPEND|O_CREAT, 0666) = 70\r\nfstat(70, {st_mode=S_IFREG|0644, st_size=13118790, ...}) = 0\r\nmmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f32777ff000\r\nfstat(70, {st_mode=S_IFREG|0644, st_size=13118790, ...}) = 0\r\nlseek(70, 13118790, SEEK_SET)           = 13118790\r\nstat(\"/etc/localtime\", {st_mode=S_IFREG|0644, st_size=165, ...}) = 0\r\nwrite(70, \"[65061] 26 Mar 09:59:04.530 # Er\"..., 111) = 111\r\nclose(70)                               = 0\r\nmunmap(0x7f32777ff000, 4096)            = 0\r\nclose(70)                               = -1 EBADF (Bad file descriptor)\r\nepoll_wait(3, {{EPOLLIN, {u32=4, u64=4}}}, 204928, 18) = 1\r\naccept(4, {sa_family=AF_INET, sin_port=htons(50586), sin_addr=inet_addr(\"10.52.88.57\")}, [11152320060842835984]) = 70\r\nfcntl(70, F_GETFL)                      = 0x2 (flags O_RDWR)\r\nfcntl(70, F_SETFL, O_RDWR|O_NONBLOCK)   = 0\r\nsetsockopt(70, SOL_TCP, TCP_NODELAY, [1], 4) = 0\r\nepoll_ctl(3, EPOLL_CTL_MOD, 70, {EPOLLIN, {u32=70, u64=70}}) = -1 ENOENT (No such file or directory)\r\nclose(70)                               = 0\r\nopen(\"./log/redis.log\", O_WRONLY|O_APPEND|O_CREAT, 0666) = 70\r\nfstat(70, {st_mode=S_IFREG|0644, st_size=13118901, ...}) = 0\r\nmmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f32777ff000\r\nfstat(70, {st_mode=S_IFREG|0644, st_size=13118901, ...}) = 0\r\nlseek(70, 13118901, SEEK_SET)           = 13118901\r\nstat(\"/etc/localtime\", {st_mode=S_IFREG|0644, st_size=165, ...}) = 0\r\nwrite(70, \"[65061] 26 Mar 09:59:04.531 # Er\"..., 111) = 111\r\nclose(70)                               = 0\r\nmunmap(0x7f32777ff000, 4096)            = 0\r\nclose(70)                               = -1 EBADF (Bad file descriptor)\r\nepoll_wait(3, {{EPOLLIN, {u32=36, u64=36}}}, 204928, 17) = 1\r\nread(36, \"*3\\r\\n$6\\r\\nEXPIRE\\r\\n$19\\r\\npsnlpHash36\"..., 16384) = 51\r\nepoll_wait(3, {{EPOLLIN, {u32=40, u64=40}}}, 204928, 13) = 1\r\nread(40, \"*3\\r\\n$5\\r\\nHMGET\\r\\n$19\\r\\npsnlpHash365\"..., 16384) = 59\r\nepoll_ctl(3, EPOLL_CTL_MOD, 40, {EPOLLIN|EPOLLOUT, {u32=40, u64=40}}) = 0\r\nepoll_wait(3, {{EPOLLOUT, {u32=40, u64=40}}}, 204928, 12) = 1\r\nwrite(40, \"*1\\r\\n$-1\\r\\n\", 9)           = 9\r\nepoll_ctl(3, EPOLL_CTL_MOD, 40, {EPOLLIN, {u32=40, u64=40}}) = 0\r\nepoll_wait(3, {{EPOLLIN, {u32=36, u64=36}}}, 204928, 12) = 1\r\nread(36, \"*8\\r\\n$5\\r\\nHMSET\\r\\n$15\\r\\nforumHash101\"..., 16384) = 113\r\n```\r\nThe output shows that when new client connected to the server, the server accpet the request and return a fd=70, but epoll_ctl on the socket is failed and return -1:（No such file or directory）and close on it.\r\nThen the open file system call also return the fd=70 and rewrite the log properly.\r\nBut the accept can not work.（this period may have network shake）\r\nIs this a bug in redis?"},"comment":{"url":"https://api.github.com/repos/antirez/redis/issues/comments/161852428","html_url":"https://github.com/antirez/redis/issues/2479#issuecomment-161852428","issue_url":"https://api.github.com/repos/antirez/redis/issues/2479","id":161852428,"user":{"login":"jaykei","id":6262594,"avatar_url":"https://avatars.githubusercontent.com/u/6262594?v=3","gravatar_id":"","url":"https://api.github.com/users/jaykei","html_url":"https://github.com/jaykei","followers_url":"https://api.github.com/users/jaykei/followers","following_url":"https://api.github.com/users/jaykei/following{/other_user}","gists_url":"https://api.github.com/users/jaykei/gists{/gist_id}","starred_url":"https://api.github.com/users/jaykei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaykei/subscriptions","organizations_url":"https://api.github.com/users/jaykei/orgs","repos_url":"https://api.github.com/users/jaykei/repos","events_url":"https://api.github.com/users/jaykei/events{/privacy}","received_events_url":"https://api.github.com/users/jaykei/received_events","type":"User","site_admin":false},"created_at":"2015-12-04T02:22:21Z","updated_at":"2015-12-04T02:22:21Z","body":"Oh, I see. I met this problem because I'm using redis 2.8 that is not the latest version.\r\n\r\nIn my redis, cancelRepilicationHandshake() was like this :\r\n```\r\nint cancelReplicationHandshake(void) {\r\n    if (server.repl_state == REDIS_REPL_TRANSFER) {                                                   \r\n        replicationAbortSyncTransfer();\r\n    } else if (server.repl_state == REDIS_REPL_CONNECTING ||                                          \r\n             server.repl_state == REDIS_REPL_RECEIVE_PONG)                                            \r\n    {   \r\n        undoConnectWithMaster();                                                                      \r\n    } else {\r\n        return 0;                                                                                     \r\n    }\r\n    return 1;                                                                                         \r\n}                                                                                                     \r\n```\r\nAs @antirez analyzed, repl_state was REDIS_REPL_RECEIVE_PSYNC.\r\nSo it just returned 0, not calling undoConnectWithMaster().\r\n\r\nBut I just checked commit logs and found that it was fixed about 2 months ago at following commit :\r\n```\r\ncommit 3e0b34cf6dbf0803f5d7aa9617a3c4497bcb5959\r\nAuthor: Kevin McGehee <mcgehee@amazon.com>\r\nDate:   Wed Oct 14 12:03:47 2015 -0700\r\n```\r\n\r\nI'm sorry that I didn't  check the latest version before making comment. I'll cancel my pull request right away.\r\nAnyway I'm happy that I re-ignited this issue, haha.\r\n\r\nThanks !"}}