message: Make sure to flush the chainstate if reindexing or importing
  If needed we have to ensure we flush the chainstate for these
  two conditions until the chain is almost syncd.
diff: @@ -3207,17 +3207,19 @@ bool static ConnectTip(CValidationState &state,
  bool result = view.Flush();
  assert(result);
  }
  +
  int64_t nTime4 = GetTimeMicros();
  nTimeFlush += nTime4 - nTime3;
  LogPrint("bench", " - Flush: %.2fms [%.2fs]\n", (nTime4 - nTime3) * 0.001, nTimeFlush * 0.000001);
  - // Write the chain state to disk, if necessary and only during IBD
  - if (!IsChainNearlySyncd())
  + // Write the chain state to disk, if necessary, and only during IBD, reindex, or importing.
  + if (!IsChainNearlySyncd() || fReindex || fImporting)
  if (!FlushStateToDisk(state, FLUSH_STATE_IF_NEEDED))
  return false;
  int64_t nTime5 = GetTimeMicros();
  nTimeChainState += nTime5 - nTime4;
  LogPrint(
  "bench", " - Writing chainstate: %.2fms [%.2fs]\n", (nTime5 - nTime4) * 0.001, nTimeChainState * 0.000001);
  +
  // Remove conflicting transactions from the mempool.
  std::list<CTransaction> txConflicted;
  mempool.removeForBlock(pblock->vtx, pindexNew->nHeight, txConflicted, !IsInitialBlockDownload());
  