oetiker / znapzend

zfs backup with remote capabilities and mbuffer integration.
www.znapzend.org
GNU General Public License v3.0
604 stars 136 forks source link

Uninitialized values and division by zero #580

Closed sempervictus closed 1 year ago

sempervictus commented 1 year ago

Arch Linux is blowing up on znapzend operations with:

$ znapzend --runonce --autoCreation --nodestroy srcpool/srcdataset
Subroutine delay redefined at /opt/znapzend/lib/Mojo/IOLoop.pm line 68.
[2022-07-24 15:53:02.44089] [3742276] [info] znapzend (PID=3742276) starting up ...
[2022-07-24 15:53:02.44116] [3742276] [info] refreshing backup plans ...
cannot open 'dstpool/dstdataset': dataset does not exist
Use of uninitialized value $backupPlan in split at /opt/znapzend/lib/ZnapZend/Time.pm line 111.
[2022-07-24 15:54:00.57422] [3742276] [info] found a valid backup plan for srcpool...
Use of uninitialized value $backupPlan in split at /opt/znapzend/lib/ZnapZend/Time.pm line 111.
Use of uninitialized value $timeFormat in substitution (s///) at /opt/znapzend/lib/ZnapZend/Time.pm line 264.
Use of uninitialized value $timeFormat in substitution (s///) at /opt/znapzend/lib/ZnapZend/Time.pm line 265.
Use of uninitialized value $timeFormat in substitution (s///) at /opt/znapzend/lib/ZnapZend/Time.pm line 266.
Use of uninitialized value $timeFormat in substitution (s///) at /opt/znapzend/lib/ZnapZend/Time.pm line 269.
Use of uninitialized value $timeFormat in pattern match (m//) at /opt/znapzend/lib/ZnapZend/Time.pm line 132.
[2022-07-24 15:54:00.57453] [3742276] [info] found a valid backup plan for srcpool/srcdataset/subdataset...
Use of uninitialized value $backupPlan in split at /opt/znapzend/lib/ZnapZend/Time.pm line 111.
Use of uninitialized value $interval in division (/) at /opt/znapzend/lib/ZnapZend/Time.pm line 53.
Illegal division by zero at /opt/znapzend/lib/ZnapZend/Time.pm line 53.

the package is built on Arch from AUR using


build() {
    cd "${pkgname}-${pkgver}"
    ./configure --prefix="/opt/${pkgname}"
    make
}

package() {
    cd "${pkgname}-${pkgver}"
    make DESTDIR="${pkgdir}" install
    mkdir -p "${pkgdir}/usr/bin" "${pkgdir}/usr/lib/systemd/system" "${pkgdir}/usr/share/man/man1"
    ln -s "/opt/${pkgname}/bin/znapzend" "${pkgdir}/usr/bin/znapzend"
    ln -s "/opt/${pkgname}/bin/znapzendzetup" "${pkgdir}/usr/bin/znapzendzetup"
    ln -s "/opt/${pkgname}/bin/znapzendztatz" "${pkgdir}/usr/bin/znapzendztatz"
    install -m 644 "init/znapzend.service" "${pkgdir}/usr/lib/systemd/system/znapzend.service"
    install -m 644 "man/znapzend.1" "man/znapzendzetup.1" "man/znapzendztatz.1" "${pkgdir}/usr/share/man/man1"
}

package was just rebuilt in a clean chroot with the same results

sempervictus commented 1 year ago

Rebuilt from master and the redefinition of delay line went away, but the uninitialized values and div by 0 persist.

sempervictus commented 1 year ago

This seems to have been introduced at some point in the past by way of incompatibility with the attributes set by znapzendzetup - re running the same invocation of it used to create the original configuration at some point in the past, regenerates the dataset user-options in a format which znapzend can use. Might be worth having some sort of safety latch for old config styles to have it bail with an informative message about those.

oetiker commented 1 year ago

some examples would be helpful

sempervictus commented 1 year ago

Using this znapzend option-set:

500g6dz2  org.znapzend:post_znap_cmd  off                                                            local
500g6dz2  org.znapzend:mbuffer_size   1G                                                             local
500g6dz2  org.znapzend:tsformat       znap-%Y%m%d-%H%M%S                                             local
500g6dz2  org.znapzend:dst_a_plan     14days=>1days,8weeks=>1weeks,24months=>1months,5years=>1years  local
500g6dz2  org.znapzend:dst_a          3t6dz2/backups/fs00/500g6dz2                         local
500g6dz2  org.znapzend:enabled        on                                                             local
500g6dz2  org.znapzend:recursive      on                                                             local
500g6dz2  org.znapzend:pre_znap_cmd   off                                                            local
500g6dz2  org.znapzend:mbuffer        off                                                            local
500g6dz2  org.znapzend:src_plan       3days=>1days,2weeks=>1weeks                                    local
500g6dz2  org.znapzend:zend_delay     0                                                              local

i get this

# znapzend --runonce --autoCreation
[2022-08-01 01:56:53.83892] [100689] [info] znapzend (PID=100689) starting up ...
[2022-08-01 01:56:53.83922] [100689] [info] refreshing backup plans ...
Use of uninitialized value $backupPlan in split at /opt/znapzend/lib/ZnapZend/Time.pm line 111.
[2022-08-01 01:57:51.70258] [100689] [info] found a valid backup plan for rpool...
[2022-08-01 01:57:51.70304] [100689] [info] found a valid backup plan for 500g6dz2...
Use of uninitialized value $backupPlan in split at /opt/znapzend/lib/ZnapZend/Time.pm line 111.
Use of uninitialized value $timeFormat in substitution (s///) at /opt/znapzend/lib/ZnapZend/Time.pm line 264.
Use of uninitialized value $timeFormat in substitution (s///) at /opt/znapzend/lib/ZnapZend/Time.pm line 265.
Use of uninitialized value $timeFormat in substitution (s///) at /opt/znapzend/lib/ZnapZend/Time.pm line 266.
Use of uninitialized value $timeFormat in substitution (s///) at /opt/znapzend/lib/ZnapZend/Time.pm line 269.
Use of uninitialized value $timeFormat in pattern match (m//) at /opt/znapzend/lib/ZnapZend/Time.pm line 132.
[2022-08-01 01:57:51.70335] [100689] [info] found a valid backup plan for 500g6dz2/local/lxc...
Use of uninitialized value $backupPlan in split at /opt/znapzend/lib/ZnapZend/Time.pm line 111.
Use of uninitialized value $interval in division (/) at /opt/znapzend/lib/ZnapZend/Time.pm line 53.
Illegal division by zero at /opt/znapzend/lib/ZnapZend/Time.pm line 53.
jimklimov commented 1 year ago

FWIW, adding --debug to command line may yield even more details about variables passing through the logic. As a shot in the dark, could the pool names starting with a digit get treated as an invalid number (maybe not by custom code in znapzend, but generally in some perl parser routine that is called)?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.