test: fix race in wait_pvmove_lv_ready with stale lvmpolld entries
authorZdenek Kabelac <zkabelac@redhat.com>
Wed, 26 Nov 2025 11:39:07 +0000 (12:39 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Wed, 26 Nov 2025 11:39:07 +0000 (12:39 +0100)
The wait_pvmove_lv_ready function could incorrectly accept stale
finished pvmove entries from lvmpolld, causing test timeouts.

When running multiple test iterations, lvmpolld retains finished
polling operations in memory. If a new iteration creates pvmove
LVs with the same names (pvmove0, pvmove1), the wait function
would find these stale entries and consider them "ready" even
though they were from previous iterations with different LVIDs.

Fix by enhancing awk_parse_init_count_in_lvmpolld_dump to only
return init_requests_count for entries with polling_finished=0,
ensuring we wait for actual active polling operations rather
than accepting stale finished entries.

Co-Authored-By: Claude <noreply@anthropic.com>
test/lib/aux_t.sh

index a8ae5f4389a4c7e4ac74540e19233b77ade371ad..33e84ece6ba435fd8571e2464096d2a216ff8052 100644 (file)
@@ -2065,9 +2065,10 @@ awk_parse_init_count_in_lvmpolld_dump() {
        $'BEGINFILE { x=0; answ=0 }' \
        $'{' \
                $'if (/.*{$/) { x++ }' \
-               $'else if (/.*}$/) { x-- }' \
-               $'else if ( x == 2 && $1 ~ "[[:space:]]*"vkey) { value=substr($2, 2); value=substr(value, 1, length(value) - 1); }' \
-               $'if ( x == 2 && value == vvalue && $1 ~ /[[:space:]]*init_requests_count/) { answ=$2 }' \
+               $'else if (/.*}$/) { x--; if (x == 1) { finished=-1; found=0 } }' \
+               $'else if ( x == 2 && $1 ~ "[[:space:]]*"vkey) { value=substr($2, 2); value=substr(value, 1, length(value) - 1); if (value == vvalue) found=1 }' \
+               $'else if ( x == 2 && found == 1 && $1 ~ /[[:space:]]*polling_finished/) { finished=$2 }' \
+               $'if ( x == 2 && found == 1 && finished == 0 && $1 ~ /[[:space:]]*init_requests_count/) { answ=$2 }' \
                $'if (answ > 0) { exit 0 }' \
        $'}' \
        $'END { printf "%d", answ }'
@@ -2092,6 +2093,7 @@ wait_pvmove_lv_ready() {
                                lvmpolld_dump > lvmpolld_dump.txt
                                all=1
                                for l in "${lvid[@]%-real}" ; do
+                                       # check_lvmpolld_init_rq_count now ignores finished entries
                                        check_lvmpolld_init_rq_count 1 "${l##LVM-}" lvid || all=0
                                done
                                [[ "$all" = 1 ]] && return
This page took 0.077172 seconds and 5 git commands to generate.