{"action":"created","issue":{"url":"https://api.github.com/repos/google/codesearch/issues/50","repository_url":"https://api.github.com/repos/google/codesearch","labels_url":"https://api.github.com/repos/google/codesearch/issues/50/labels{/name}","comments_url":"https://api.github.com/repos/google/codesearch/issues/50/comments","events_url":"https://api.github.com/repos/google/codesearch/issues/50/events","html_url":"https://github.com/google/codesearch/issues/50","id":99379128,"number":50,"title":"index: merge of index fails","user":{"login":"frederich","id":274349,"avatar_url":"https://avatars.githubusercontent.com/u/274349?v=3","gravatar_id":"","url":"https://api.github.com/users/frederich","html_url":"https://github.com/frederich","followers_url":"https://api.github.com/users/frederich/followers","following_url":"https://api.github.com/users/frederich/following{/other_user}","gists_url":"https://api.github.com/users/frederich/gists{/gist_id}","starred_url":"https://api.github.com/users/frederich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frederich/subscriptions","organizations_url":"https://api.github.com/users/frederich/orgs","repos_url":"https://api.github.com/users/frederich/repos","events_url":"https://api.github.com/users/frederich/events{/privacy}","received_events_url":"https://api.github.com/users/frederich/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-06T07:50:53Z","updated_at":"2016-05-03T07:46:06Z","closed_at":null,"body":"I've tried to index the Go sources on Windows. The first run of Cindex is like expected. The second run doesn't remove `.csearchindex~` and has created a second file `.csearchindex~~`. I don't know whether the merge of `.csearchindex` and `.csearchindex~` has been successful.\r\n\r\nThe expected behaviour is `.csearchindex` and `.csearchindex~` will be merged and `.csearchindex~` will removed.\r\n\r\nOS: Windows 7\r\nGo: go1.5rc1\r\n\r\n### First Run\r\n```\r\nv% cindex go\r\n2015/08/06 09:36:34 index E:\\home\\visfj\\go\r\n2015/08/06 09:36:34 flush index\r\n2015/08/06 09:36:34 merge 0 files + mem\r\n2015/08/06 09:36:35 39563770 data bytes, 9212960 index bytes\r\n2015/08/06 09:36:35 done\r\nv% ls -al\r\ntotal 9068\r\ndrwxr-xr-x 1 visfj Domänen-Benutzer       0 Aug  6 09:36 .\r\ndrwxr-xr-x 1 visfj Domänen-Benutzer       0 Jul 30 13:22 ..\r\n-rw-r--r-- 1 visfj Domänen-Benutzer    6213 Aug  6 08:36 .bash_history\r\n-rw-r--r-- 1 visfj Domänen-Benutzer     422 Aug  5 11:29 .bashrc\r\n-rw-r--r-- 1 visfj Domänen-Benutzer 9212960 Aug  6 09:36 .csearchindex\r\n-rw-r--r-- 1 visfj Domänen-Benutzer     105 Aug  5 14:26 .gitconfig\r\n-rw-r--r-- 1 visfj Domänen-Benutzer     114 Jul 31 13:56 .gitcookies\r\n```\r\n\r\n### Second Run\r\n```\r\nv% cindex\r\n2015/08/06 09:36:45 index E:\\home\\visfj\\go\r\n2015/08/06 09:36:46 flush index\r\n2015/08/06 09:36:46 merge 0 files + mem\r\n2015/08/06 09:36:46 39563770 data bytes, 9212960 index bytes\r\n2015/08/06 09:36:46 merge E:\\home\\visfj\\.csearchindex E:\\home\\visfj\\.csearchindex~\r\n2015/08/06 09:36:46 done\r\nv% ls -al\r\ntotal 27068\r\ndrwxr-xr-x 1 visfj Domänen-Benutzer       0 Aug  6 09:36 .\r\ndrwxr-xr-x 1 visfj Domänen-Benutzer       0 Jul 30 13:22 ..\r\n-rw-r--r-- 1 visfj Domänen-Benutzer    6213 Aug  6 08:36 .bash_history\r\n-rw-r--r-- 1 visfj Domänen-Benutzer     422 Aug  5 11:29 .bashrc\r\n-rw-r--r-- 1 visfj Domänen-Benutzer 9212960 Aug  6 09:36 .csearchindex\r\n-rw-r--r-- 1 visfj Domänen-Benutzer 9212960 Aug  6 09:36 .csearchindex~\r\n-rw-r--r-- 1 visfj Domänen-Benutzer 9212944 Aug  6 09:36 .csearchindex~~\r\n-rw-r--r-- 1 visfj Domänen-Benutzer     105 Aug  5 14:26 .gitconfig\r\n-rw-r--r-- 1 visfj Domänen-Benutzer     114 Jul 31 13:56 .gitcookies\r\n```"},"comment":{"url":"https://api.github.com/repos/google/codesearch/issues/comments/216460476","html_url":"https://github.com/google/codesearch/issues/50#issuecomment-216460476","issue_url":"https://api.github.com/repos/google/codesearch/issues/50","id":216460476,"user":{"login":"abingham","id":79224,"avatar_url":"https://avatars.githubusercontent.com/u/79224?v=3","gravatar_id":"","url":"https://api.github.com/users/abingham","html_url":"https://github.com/abingham","followers_url":"https://api.github.com/users/abingham/followers","following_url":"https://api.github.com/users/abingham/following{/other_user}","gists_url":"https://api.github.com/users/abingham/gists{/gist_id}","starred_url":"https://api.github.com/users/abingham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abingham/subscriptions","organizations_url":"https://api.github.com/users/abingham/orgs","repos_url":"https://api.github.com/users/abingham/repos","events_url":"https://api.github.com/users/abingham/events{/privacy}","received_events_url":"https://api.github.com/users/abingham/received_events","type":"User","site_admin":false},"created_at":"2016-05-03T07:46:06Z","updated_at":"2016-05-03T07:46:06Z","body":"I've looked into this a bit, and the proximal problem seems to be that the `os.Rename` at the end of `cindex.main()` (cindex.go:156 on what I've got right now) is failing. If I capture its error and print it, it claims:\r\n\r\n```\r\n2016/05/03 09:30:05 rename error rename C:\\Users\\mrsdev\\.csearchindex~~ C:\\Users\\mrsdev\\.csearchindex: The process cannot access the file because it is being used by another process.\r\n```\r\n\r\nI'm no go expert (or even novice), but I dug into the merge code a bit, and it appears that the index file is being accessed through a mmap (see `codesearch/index/read.Open`). I guess the mmap is holding on to the file longer than we want, or perhaps there's a missing call to release it.\r\n\r\nI'm happy to help sort this out, but I'm a bit out of my depth with go here, and I don't really have a lot of time to devote to this...I would just like codesearch to work! Any ideas?"}}