The test fails consistently with this seed -Dtests.seed=2719714750176374101:2498146487036328796 on trunk.
I added prints to the test for when it marks a document for deletion (it adds a term) and then traversing this term's DocsEnum. I see that the lists are off by 1 (i.e instead of 0, 3, 6, 9 ... it is 0, 2, 5, 8). So I don't think the failure is related to the facets code at all.
I've noticed the following:
- If I disable RandomIW, it passes
- If I disable RandomIW.addDocument call to maybeCommit, it passes too.
- Disabling maybeCommit.switchDoDocValues has no effect.
It's the call to w.commit() which causes the IDs to offset by 1.
Since RIW.flushAt is set to 51 (w/ the above seed), you can reduce the number of docs to index to 53 and the bug will be exposed (it didn't reproduce w/ N_DOCS=52). I'll try to isolate this bug to a standalone testcase and then run on 3x too.