Here is v9- with:
1/ to also pgStatFlushInProgress when we're-queueing
pgstat_prep_pending_from_entry_ref(PgStat_EntryRef *entry_ref)
{
...
....
else if (pgStatFlushInProgress && entry_ref->flushed_this_pass)
...
...
}
2/ Added an `Assert(!pgStatFlushInProgress);` inside pgstat_report_stat().
This should never be called while there is a flush in progress.
--
Sami