Skip to content

PDB Corruption (Workaround) #103

@pschapman

Description

@pschapman

It appears that simultaneous write to the PDB and a ztp service restart cause the PDB to become corrupt. This will stop additional deployments.

Issuing ztp show provisioning dumps an error.

ztp@ztp:~$ sudo ztp show provisioning 
[sudo] password for ztp: 
2025-12-04 15:25:32:   persistent_store: ERROR: Error in reading from store file
2025-12-04 15:25:32:   persistent_store: ERROR: Extra data: line 5103 column 2 - line 5148 column 2 (char 175123 - 176532)
2025-12-04 15:25:32:   persistent_store: ERROR: Error in reading from store file
2025-12-04 15:25:32:   persistent_store: ERROR: Extra data: line 5103 column 2 - line 5148 column 2 (char 175123 - 176532)
2025-12-04 15:25:32:   persistent_store: ERROR: Error in reading from store file
2025-12-04 15:25:32:   persistent_store: ERROR: Extra data: line 5103 column 2 - line 5148 column 2 (char 175123 - 176532)
#######################################################################################################
#  Timestamp  |  IP Address  |  Temp ID  |  MAC Address  |  Real IDs  |  Matched Keystore  |  Status  #
#=====================================================================================================#
#######################################################################################################

Workaround

Detect JSON corruption during ZTP restart. Follow instructions embedded in script below.

#!/bin/bash
################################################################################
# Description  : Detects and removes corrupt ZTP provisioning database file (PDB)
#
# Author       : Paul Chapman (ConvergeOne)
#
# Syntax       : sh check_pdb.sh
# Example      : sh check_pdb.sh
#
# Requires JQuery. 'apt install jq'
#
# NOTE: Don't forget to 'chmod +x' the script file. :)
#
# Best solution is to execute script when ZTP is restarted.
# Edit '/etc/systemd/system/ztp.service' Change ExecStart line to:
# ExecStart=/bin/bash -c 'cd /bin; /home/ztp/check_pdb.sh;  python ztp run'
#
# NOTE: Alter path to check_pdb.sh file if needed.
#
# To execute as a Cron job, add "ztp service restart" to the 'if...fi' conditional.
#
################################################################################

jq . /etc/ztp/pdb 1> /dev/null
if [ $? -ne 0 ]; then
    mv /etc/ztp/pdb /etc/ztp/pdb.bad
    printf '%s Corrupt PDB found. PDB cleared and ZTP restarted.\n' "$(date --rfc-3339=seconds)" >> /home/ztp/check_pdb.log
fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions