It seems `optimizeMutex` is there to avoid doing multiple optimizes but also not accumulate pending ones. Lock.tryLock could also work, I guess.

Back to the merge policy. It is acquired from the indexWriter so is it OK to change it while not have a read lock? the indexWriter may have been changed/closed. I'm not sure just want to make sure it's considered.