<varname>object</varname> is not <literal>wal</literal>,
or if <xref linkend="guc-track-wal-io-timing"/> is enabled
and <varname>object</varname> is <literal>wal</literal>,
- otherwise zero)
+ otherwise zero). This may include time spent waiting for a
+ read started by another backend. In that case
+ <structfield>reads</structfield> may still be zero.
</para>
</entry>
</row>
needed_wait = true;
/*
- * The IO operation itself was already counted earlier, in
- * AsyncReadBuffers(), this just accounts for the wait time.
+ * This just accounts for the wait time. The IO operation
+ * itself was already counted earlier in AsyncReadBuffers() --
+ * either by us or by another backend if this is a foreign IO.
*/
pgstat_count_io_op_time(io_object, io_context, IOOP_READ,
io_start, 0, 0);
* A secondary benefit is that this would allow us to measure the time in
* pgaio_io_acquire() without causing undue timer overhead in the common,
* non-blocking, case. However, currently the pgstats infrastructure
- * doesn't really allow that, as it a) asserts that an operation can't
- * have time without operations b) doesn't have an API to report
+ * doesn't really allow that because it doesn't have an API to report
* "accumulated" time.
*/
ioh = pgaio_io_acquire_nb(CurrentResourceOwner, &operation->io_return);
/*
* Check that stats have not been counted for any combination of IOObject,
- * IOContext, and IOOp which are not tracked for the passed-in BackendType. If
- * stats are tracked for this combination and IO times are non-zero, counts
- * should be non-zero.
+ * IOContext, and IOOp which are not tracked for the passed-in BackendType.
+ * Non-zero time with a zero operation count is allowed as there are cases
+ * where this may be appropriate -- like when a backend is waiting on IO
+ * initiated by another backend.
*
* The passed-in PgStat_BktypeIO must contain stats from the BackendType
* specified by the second parameter. Caller is responsible for locking the
{
for (int io_op = 0; io_op < IOOP_NUM_TYPES; io_op++)
{
- /* we do track it */
- if (pgstat_tracks_io_op(bktype, io_object, io_context, io_op))
- {
- /* ensure that if IO times are non-zero, counts are > 0 */
- if (backend_io->times[io_object][io_context][io_op] != 0 &&
- backend_io->counts[io_object][io_context][io_op] <= 0)
- return false;
-
- continue;
- }
-
/* we don't track it, and it is not 0 */
- if (backend_io->counts[io_object][io_context][io_op] != 0)
+ if (!pgstat_tracks_io_op(bktype, io_object, io_context, io_op) &&
+ (backend_io->counts[io_object][io_context][io_op] != 0 ||
+ backend_io->times[io_object][io_context][io_op] != 0))
return false;
}
}