The expected result is this

but every now and then artifacts appear like this

The artifacts seem to depend on the order of the unified polygons. Spade's r-tree is used to union polygons in parallel.
For some reason applying union on these polygons sequentially:

causes this result:
