annoy: On Disk Build Failing v1.16.0

The latest version fails to build the index on disk.

Building the index results in

Error truncating file: Input/output error

Same code works on 1.15.2.

Python 3.7 Windows 10

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17

Most upvoted comments

@AlxndrMlk Are you using Windows?

In that case I guess this is the bug I opened in #487 (or at least related). In your case you’re not having errors with ftruncate on too large file I guess but as far as I can tell, no matter how big the file is, on_disk_build() should fail on Windows.

It is due to the fact that a file is created, then mmaped, and when build is called then last chunks are truncated. But truncation cannot happen on Windows when a file is already mmap-ed, cf. here - honnestly I thought it was OK when in the same process but I found it wasn’t when debugging… In order to fix I guess one has to follow Microsoft’s guidelines:

If CreateFileMapping is called to create a file mapping object for hFile, UnmapViewOfFile must be called first to unmap all views and call CloseHandle to close the file mapping object before you can call SetEndOfFile.

I’ll try to push a PR to deal with it when I come back from my vacations 👓

@vbod, thanks! I’ll check as soon as I find a while to do so.

Best, Aleksander

@AlxndrMlk @barrycarey If you ever have the opportunity to test with the master branch, it’d be awesome to know if this PR does fix it indeed! Please tell me if it does - or not 😉

Yes @vbod, exactly, Win 10.

Seems that’s the issue.

Have a great holiday, by the way! 😎

odd. will see if i can repro.

ok, no rush! really appreciate it