Skip to content

contest: retry when unable to load input files - #90

Open
matttbe wants to merge 2 commits into
linux-netdev:mainfrom
matttbe:contest-retry-empty
Open

contest: retry when unable to load input files#90
matttbe wants to merge 2 commits into
linux-netdev:mainfrom
matttbe:contest-retry-empty

Conversation

@matttbe

@matttbe matttbe commented Aug 20, 2026

Copy link
Copy Markdown
Member

The contest service was unable to load the 'branch_info' input file twice yesterday. Probably because it was being updated:

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Catch the error, and retry max 4 more times with the same delay.

The contest service was unable to load the 'branch_info' input file
twice yesterday. Probably because it was being updated:

  json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Catch the error, and retry later.

Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
Just to be able to see that there is something wrong going on.

After this arbitrary limit, the service will crash, and this will be
more visible than letting the service retrying over and over without
actually updating Patchwork.

The limit is set to 4, which should correspond to 5 minutes before
reporting an error with these files if they stay corrupted for some
reasons.

Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
@matttbe
matttbe requested a review from kuba-moo August 20, 2026 10:30
@kuba-moo

Copy link
Copy Markdown
Contributor

I thought we had some "atomic update" method for updating the JSON files. Does it still race? Maybe some files are missing using that atomic update API?

@matttbe

matttbe commented Aug 23, 2026

Copy link
Copy Markdown
Member Author

From what I understood, nipa-br-faker.service is executed every 2 minutes, and it combines branches-info-nn.json and branches-info-hw.json into branches-info.json used by the "contest" service. The faker service reads the 2 json, combines them, opens the output file, truncating the file first, then writes it and closes it:

def combine_infos(config):
paths = config.get("input", "infos", fallback="").split(',')
if not paths:
return
infos = {}
for path in paths:
with open(path, "r") as fp:
infos.update(json.load(fp))
with open(config.get("output", "info"), 'w') as fp:
json.dump(infos, fp)

It looks like there is a very small window where the file can be empty.

@kuba-moo

Copy link
Copy Markdown
Contributor

That's the one, it should be doing an "atomic" write, write to a temp file and rename it overriding the existing file, instead of dumping directly to the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants