I have the same problem described in this old thread:
http://dovecot.org/list/dovecot/2012-April/135162.html I have done some debugging, by adding log messages to squat_uidlist_map_header and squat_trie_refresh.
I have found that the "wrong indexid" warning is always triggered under the following conditions
- uidlist->hdr.indexid != 0
- uidlist->trie->hdr.indexid == 0
- squat_trie_is_file_stale(trie) == 0
In other words it looks like the squat_uidlist_map_header function is called with an uninitialized trie, an initialized header, and a current (not stale) file. Because of the latter, squat_trie_refresh never calls squat_trie_open, the trie stays uninitialized and later triggers the warning. In addition the search results will only include mails added to the mailbox after the warning.
By replacing the call to squat_trie_refresh with squat_trie_open in squat_uidlist_map_header, the warning no longer happens. Patch is attached. I am not sure this is the correct way of fixing the problem, but it works reliably.