Proxmox pvescheduler logs « invalid json data in pve-replication-state.json » every minute when the file holds [] instead of {}

While auditing a single-node Proxmox VE host I found the journal full of one line, repeated 18,156 times over twelve days:

replication: invalid json data in '/var/lib/pve-manager/pve-replication-state.json'

The node has no replication jobs at all. The file it complains about was two bytes long and contained [], which is valid JSON.

TL;DR — pvescheduler’s replication state loader accepts an empty file or a JSON object ({…}) and nothing else. A file containing [] fails its untaint regex and dies on every scheduler tick, once a minute, forever. Back the file up, write {} into it, and the error stops at the next tick. No restart needed.

The setup

One Proxmox VE 9 node on Debian 13, two QEMU virtual machines, no cluster, no storage replication configured (pvesr list prints an empty table). pvescheduler is the daemon that runs scheduled jobs such as backups and storage replication; it wakes up every minute. It keeps the replication state, meaning the last sync time per guest, in /var/lib/pve-manager/pve-replication-state.json, a JSON object keyed by guest id.

Three possible contents of the state file: an empty file returns the default state, an object is decoded, an array fails the untaint regex and raises the error every minute

What I expected

With no replication jobs I expected either no state file at all, or an empty object {}. An error mentioning this file would mean a real replication job in trouble, with a real sync failure behind it.

What actually happens

journalctl -p err -u pvescheduler -S -7d --no-pager | tail -2
Sep 05 18:11:14 node pvescheduler[1162481]: replication: invalid json data in '/var/lib/pve-manager/pve-replication-state.json'
Sep 05 18:12:14 node pvescheduler[1164510]: replication: invalid json data in '/var/lib/pve-manager/pve-replication-state.json'

One line per minute, so the daily count is 1,440 and the total since the last boot twelve days earlier was 18,156. The scheduler itself kept working; only the replication step died, and it died silently as far as the web UI is concerned. Nothing else about the node was affected.

The file:

ls -la /var/lib/pve-manager/pve-replication-state.json
# -rw-r--r-- 1 root root 2 Aug 24 05:34 /var/lib/pve-manager/pve-replication-state.json
cat /var/lib/pve-manager/pve-replication-state.json
# []

Two bytes, an empty JSON array, with a modification time equal to the last boot. python3 -m json.tool parses it without complaint, which is why « invalid json data » sent me looking in the wrong direction first.

The fix

Only do this when pvesr list shows no replication jobs. On a node that does replicate, the file carries the last-sync state of every job, and blanking it is not a repair.

pvesr list                     # must be empty before you touch the file
cp -a /var/lib/pve-manager/pve-replication-state.json /root/pve-replication-state.json.bak
echo '{}' > /var/lib/pve-manager/pve-replication-state.json
# wait for the next tick, then:
journalctl -u pvescheduler -S -2min --no-pager | grep -c 'invalid json'
# 0

The count went to zero at the next minute. I did not restart pvescheduler; it re-reads the file on every run. A host reboot later the same day left the file at {}, so whatever wrote [] did not write it again.

Why it works

The loader is read_state in PVE/ReplicationState.pm, shipped by pve-manager (this is 9.2.11; 9.2.3 had the same behaviour):

sub read_state {
    return {} if !-e $state_path;
    my $raw = PVE::Tools::file_get_contents($state_path, (1024 * 1024));
    return {} if $raw eq '';
    # untaint $raw
    if ($raw =~ m/^(\{.*\})$/) {
        return decode_json($1);
    }
    die "invalid json data in '$state_path'\n";
}

Three cases. A missing or empty file returns a fresh empty state. A string that starts with { and ends with } is passed to decode_json. Anything else dies with the generic message, before any JSON parsing happens. So the check is a shape check, not a parse: [] is perfectly valid JSON and still fails, because the regex only lets an object through. The same pattern, with the same message, sits in PVE/Jobs.pm for the per-job state files.

The regex is there to untaint the string for Perl’s taint mode, which is why it is so strict. It has no /s modifier either, so . does not match newlines; a pretty-printed, multi-line object would fail the same way. That part I did not try.

I could not find what wrote [] into the file. The timestamp matched the boot time, and nothing in the journal around that minute mentions replication. If you know the writer, the comment section is open.

What I did not test

  • Whether pve-manager 9.2.11 would have rewritten the file by itself. I upgraded from 9.2.3 the same afternoon, but I fixed the file first.
  • Nodes with actual replication jobs. There the file has content worth keeping; compare it against pvesr status before deciding anything.
  • A multi-line JSON object in the file. By the regex it should fail; I have not seen it happen.
  • Clustered nodes. This was a single node with local storage only.

Facts

context: single-node Proxmox VE 9.2 on Debian 13, no replication jobs, pvescheduler running every minute
problem: journal shows "replication: invalid json data in '/var/lib/pve-manager/pve-replication-state.json'" once a minute; the file contains the valid JSON text []
solution: with pvesr list empty, back the file up and write {} into it; read_state only accepts an empty file or a JSON object matching ^(\{.*\})$
verified_on: 2026-09-05
applies_to: [Proxmox VE 9.2.3, Proxmox VE 9.2.11, pve-manager PVE/ReplicationState.pm and PVE/Jobs.pm]
does_not_apply_to: [nodes with configured replication jobs, where the file holds real last-sync state]

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Retour en haut