Remove misleading read stream asserts in a few users
authorMelanie Plageman <melanieplageman@gmail.com>
Thu, 3 Apr 2025 22:22:37 +0000 (18:22 -0400)
committerMelanie Plageman <melanieplageman@gmail.com>
Thu, 3 Apr 2025 22:22:37 +0000 (18:22 -0400)
Several read stream users asserted that the read stream was exhausted
after looping on that very condition. It was pointed out in an a
review of an as-of-yet uncommitted read stream user [1] that this was
confusing and could lead the reader to think there was a possibility of
some kind of race condition. Remove these asserts.

[1] https://postgr.es/m/F9ACE8D0-B807-4A17-B6BD-87EF0717983D%40yesql.se

contrib/amcheck/verify_heapam.c
src/backend/access/gist/gistvacuum.c
src/backend/access/nbtree/nbtree.c
src/backend/access/spgist/spgvacuum.c

index 1970fc8620aeb2ccd4e355f476c68e4f2e66add0..2152d8ee577cbd6f2c0067f5fde90412b8f577e3 100644 (file)
@@ -853,8 +853,6 @@ verify_heapam(PG_FUNCTION_ARGS)
            break;
    }
 
-   /* Ensure that the stream is completely read */
-   Assert(read_stream_next_buffer(stream, NULL) == InvalidBuffer);
    read_stream_end(stream);
 
    if (vmbuffer != InvalidBuffer)
index ce9d78d78d650f4374dcc8882381cfd46bfa3120..6a359c98c608e703c5f687f71e4501b18bf91aeb 100644 (file)
@@ -254,8 +254,6 @@ gistvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
            gistvacuumpage(&vstate, buf);
        }
 
-       Assert(read_stream_next_buffer(stream, NULL) == InvalidBuffer);
-
        /*
         * We have to reset the read stream to use it again. After returning
         * InvalidBuffer, the read stream API won't invoke our callback again
index 4a0bf069f995474b511a1bd9d69e05e17b45abe2..a99667eb2bde1dca1ceffc6498f24ef21a7fcd21 100644 (file)
@@ -1117,8 +1117,6 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
                                             current_block);
        }
 
-       Assert(read_stream_next_buffer(stream, NULL) == InvalidBuffer);
-
        /*
         * We have to reset the read stream to use it again. After returning
         * InvalidBuffer, the read stream API won't invoke our callback again
index b3df2d89074956056ecf50fbd2caf62406352498..81171f354518e8d59302e6d68180f3c8bf7120b0 100644 (file)
@@ -879,8 +879,6 @@ spgvacuumscan(spgBulkDeleteState *bds)
                spgprocesspending(bds);
        }
 
-       Assert(read_stream_next_buffer(stream, NULL) == InvalidBuffer);
-
        /*
         * We have to reset the read stream to use it again. After returning
         * InvalidBuffer, the read stream API won't invoke our callback again