Grub fake recordfail caused by /etc/grub.d/00_header

So I have my grub set up to show at every boot, with a timeout of 10 seconds.

Lately, though, it's been reverting to 30 seconds. I tracked this down to what is known as a 'recordfail'... the machine failed to properly record a clean shutdown... apparently... but not really.

In perusing the code in /etc/grub.d/00_header, it shows:
quick_boot="1"

Then further down it shows:

if [ "$quick_boot" = 1 ]; then
    cat <<EOF
function recordfail {
  set recordfail=1
EOF

There's that fake recordfail!

And if recordfail:

make_timeout ()
{
    cat << EOF
if [ "\${recordfail}" = 1 ] ; then
  set timeout=${GRUB_RECORDFAIL_TIMEOUT:-30}
else
EOF

That's a bug. Not really sure how quick_boot got set to 1. Perhaps when I disabled suspend, hibernation, sleep and hybrid sleep?

sudo systemctl stop sleep.target suspend.target hibernate.target hybrid-sleep.target

sudo systemctl disable sleep.target suspend.target hibernate.target hybrid-sleep.target

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

However, when I set quick_boot="0", it still reverts to 30 seconds!

So I continued tracking down the problem... in /etc/grub.d/10_linux, it sets quick_boot="1", so I set it to "0" there, too.

And in that file:

 if [ "$quick_boot" = 1 ]; then
      echo "	recordfail" | sed "s/^/$submenu_indentation/"
  fi

And the same in /etc/grud.d/10_linux_zfs:
quick_boot="1"
and...

    if [ "${quick_boot}" = 1 ]; then
        echo "${submenu_indentation}	recordfail"
    fi

And the same thing in /etc/grub.d/30_os_prober:
quick_boot="1"
and...

adjust_timeout () {
  if [ "$quick_boot" = 1 ] && [ "x${found_other_os}" != "x" ]; then
    cat << EOF
set timeout_style=menu
if [ "\${timeout}" = 0 ]; then
  set timeout=30
fi
EOF
  fi
}

This thing's just insistent on setting quick_boot="1", which triggers a fake recordfail, which makes grub show up for 30 seconds!

I set quick_boot="0" for all of the above. Now to reboot...

[EDIT]
Nope, still at 30 seconds. Anyone got any ideas?

[EDIT 2]
Trying:
sudo sed -i "/recordfail_broken=/{s/1/0/}" /etc/grub.d/00_header
sudo update-grub
sudo reboot

[EDIT 3]
Nope, still at 30 seconds.

[EDIT 4]
Trying this:
In /etc/grub.d create two files and make them executable...

/etc/grub.d/25_pre-os-prober

#! /bin/sh
set -e
# Save the $timeout and $timeout_style values set by /etc/grub.d/00_header
# before /etc/grub.d/30_os-prober messes them up.
cat << EOF
set timeout_bak=\${timeout}
set timeout_style_bak=\${timeout_style}
EOF

/etc/grub.d/35_post-os-prober

#! /bin/sh
set -e
# Reset $timeout and $timeout_style to their original values
# set by /etc/grub.d/00_header before /etc/grub.d/30_os-prober messed them up.
cat << EOF
set timeout=\${timeout_bak}
set timeout_style=\${timeout_style_bak}
EOF

[EDIT 5]
Nope, that didn't work, either. Ok, I'm hacking the code.

/etc/grub.d/00_header:

make_timeout ()
{
    cat << EOF
#if [ "\${recordfail}" = 1 ] ; then
if true=true ; then
  set timeout=${GRUB_RECORDFAIL_TIMEOUT:-15}
else
EOF

If that doesn't work, then the timeout is being set elsewhere.

[EDIT 6]
Nope, that didn't work, either.

Trying:
/etc/grub.d/30_os-prober

adjust_timeout () {
# Line below is added 23 Dec 2022
  set timeout=15
  if [ "$quick_boot" = 1 ] && [ "x${found_other_os}" != "x" ]; then
    cat << EOF
set timeout_style=menu
if [ "\${timeout}" = 0 ]; then
  set timeout=15
fi
EOF
  fi
}

[EDIT 7]
Nope, that didn't work, either. Something else has got to be setting the grub menu timeout. I'm reverting all the changes until I can do more research.

This issue is apparently long-standing... there's discussion of it from as long as 8 years ago. It arises when using either UEFI, LVM or ZFS, apparently, and the Ubuntu devs haven't gotten around to fixing it. Strange that the grub menu worked perfectly for so long, only to start acting up over the past two days. Something must have triggered it.

Are you running sudo update-grub after making changes to the grub file?

Yes. It apparently doesn't matter, what with the code used to build the grub being borked for going on 8 years. I'm attempting to save the variables I want preserved before the whole /etc/grub.d/ code chain kicks in, then restoring it at the end of that chain, but apparently something after all that is setting grub timeout to 30 seconds.

It's been dubbed the RecordFail Issue. The Ubuntu devs decided that if you're using UEFI or LVM or ZFS, the grub would pop up for 30 seconds regardless... what's weird is that it worked before, and only started malfunctioning (ie: functioning the way the Ubuntu devs intended) a couple days ago... some code update changed something, perhaps?