{"action":"closed","issue":{"url":"https://api.github.com/repos/alibaba/canal/issues/692","repository_url":"https://api.github.com/repos/alibaba/canal","labels_url":"https://api.github.com/repos/alibaba/canal/issues/692/labels{/name}","comments_url":"https://api.github.com/repos/alibaba/canal/issues/692/comments","events_url":"https://api.github.com/repos/alibaba/canal/issues/692/events","html_url":"https://github.com/alibaba/canal/issues/692","id":331570509,"node_id":"MDU6SXNzdWUzMzE1NzA1MDk=","number":692,"title":"指定位点进行同步的的时候使用时间戳指定的问题","user":{"login":"yriiolik","id":3438272,"node_id":"MDQ6VXNlcjM0MzgyNzI=","avatar_url":"https://avatars1.githubusercontent.com/u/3438272?v=4","gravatar_id":"","url":"https://api.github.com/users/yriiolik","html_url":"https://github.com/yriiolik","followers_url":"https://api.github.com/users/yriiolik/followers","following_url":"https://api.github.com/users/yriiolik/following{/other_user}","gists_url":"https://api.github.com/users/yriiolik/gists{/gist_id}","starred_url":"https://api.github.com/users/yriiolik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yriiolik/subscriptions","organizations_url":"https://api.github.com/users/yriiolik/orgs","repos_url":"https://api.github.com/users/yriiolik/repos","events_url":"https://api.github.com/users/yriiolik/events{/privacy}","received_events_url":"https://api.github.com/users/yriiolik/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-12T12:41:59Z","updated_at":"2018-10-24T09:56:10Z","closed_at":"2018-10-24T09:56:10Z","author_association":"NONE","body":"如果只使用时间戳指定，不使用binlog文件名辅助，代码会去获取头尾位置的binlog文件，这个时候如果dba粗暴管理或者其他情况导致binlog文件被物理删除，会获取不到binlog起始文件导致报错。\r\n\r\n关键代码：\r\n```\r\nclass MysqlEventParser\r\n。。。\r\n// 根据时间查找binlog位置\r\n    private EntryPosition findByStartTimeStamp(MysqlConnection mysqlConnection, Long startTimestamp) {\r\n        EntryPosition endPosition = findEndPosition(mysqlConnection);\r\n        EntryPosition startPosition = findStartPosition(mysqlConnection);\r\n。。。\r\n\r\n  /* 查询当前的binlog位置\r\n     */\r\n    private EntryPosition findStartPosition(MysqlConnection mysqlConnection) {\r\n        try {\r\n            ResultSetPacket packet = mysqlConnection.query(\"show binlog events limit 1\");\r\n            List<String> fields = packet.getFieldValues();\r\n            if (CollectionUtils.isEmpty(fields)) {\r\n                throw new CanalParseException(\"command : 'show binlog events limit 1' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation\");\r\n            }\r\n            EntryPosition endPosition = new EntryPosition(fields.get(0), Long.valueOf(fields.get(1)));\r\n            return endPosition;\r\n        } catch (IOException e) {\r\n            throw new CanalParseException(\"command : 'show binlog events limit 1' has an error!\", e);\r\n        }\r\n\r\n    }\r\n\r\n```\r\n \r\nshow binlog events limit 1 的时候会报错：\r\n\r\n> MySQL [(none)]> show binlog events limit 1;\r\n> ERROR 29 (HY000): File './mysqlmaster-bin.000001' not found (Errcode: 2 - No such file or directory)\r\n\r\n是不是使用 show binary logs; 命令获取 size 大于 0 的文件，然后再使用 show binlog events 来获取起始位点信息会好一点？"}}
{"actor":{"display_login":"agapple"}}