[Bug]: FileSequence: CLI processes with different TMPDIR use separate sequence counters, sporadic Duplicate entry on oc_job_runs in 35.0.3 (after #65434/#65425)
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 22/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- linux, mysql, php
- Domaine
- backend, distributed-systems
Piste de recherche
Start with FileSequence and ITempManager::getTempBaseDir() to see how the counter directory is derived from TMPDIR and related settings, then look at JobRuns::started where the duplicate insert on oc_job_runs fails. Reproducing needs two CLI processes with different TMPDIR values. Done would mean both processes share one counter, or the duplicate is retried, with the behaviour covered by a test.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
On Nextcloud 35.0.3.2 (which includes #65425, the fix for #65434), sporadic Duplicate entry '<id>' for key 'PRIMARY' errors on oc_job_runs still occurred, roughly 5 per day, always in OC\BackgroundJob\JobRuns::started called from cron.php. The cause was not the argument order but that two CLI processes of the same instance used different counter directories, because FileSequence derives its directory from the per-process temp base dir (TMPDIR etc.). After giving both processes the same TMPDIR, the errors stopped completely (0 in 7 days, ~35 expected).
Environment
- Nextcloud 35.0.3.2, MariaDB, Linux
cron.phpevery 5 minutes from the crontab of the Nextcloud user, run withTMPDIR=/home/<user>/tmp/(set in that crontab by the hosting panel, KeyHelp)occ background-job:worker --interval=1 --stop_after=10mas a systemd service of the same user, withoutTMPDIR(so it falls back to/tmp)- Web requests use
APCuSequence, only CLI processes useFileSequence
Cause
FileSequence keeps its counters in <temp base dir>/sfi_file_sequence_<instanceid>/seq-NNN.slots. The temp base dir comes from ITempManager::getTempBaseDir() (config tempdirectory, upload_tmp_dir, TMP, TEMP, TMPDIR, sys_get_temp_dir()).
So cron.php used /home/<user>/tmp/sfi_file_sequence_<id>/ and the worker used /tmp/sfi_file_sequence_<id>/: two independent counters for the same instance, same server id, same CLI bit. The worker creates about 17 job runs per second, so a cron start collides with a worker run in the same millisecond with a probability of about 1.7 %. Both then get sequence 0 and the second insert fails. With 288 cron starts per day this gives about 5 errors per day, which matches what we saw. All 9 rows we examined had cli=1, seq=0, and every error was at the :x5 cron start.
Evidence
- The slot files in the cron temp dir changed only at the :x5 marks; the files in
/tmpchanged every second. - 9 errors between 13 Nov (update to 35.0.3.2) and 15 Nov 01:00.
- On 15 Nov 10:59 the systemd unit got
Environment=TMPDIR=/home/<user>/tmp/(same as cron). Since then 0 errors in 7 days, and the/tmpcounter directory is no longer written.
Workaround
Use the same temp directory for every CLI entry point (cron, systemd units, manual occ), or set 'tempdirectory' in config.php.
Suggestions
The coordination path should not depend on per-process environment variables. For example:
- use a fixed directory below the data directory (or
tempdirectoryonly), or - add a setup check that warns when CLI processes resolve different temp base dirs, or
- treat a duplicate in
JobRuns::startedas retryable (generate a new id) instead of aborting the run.
Related: #65434 (closed, locked), #65425.
- Langage dominant
- PHP
- Étoiles
- 37.6k
- Forks
- 5.4k
- Merge moyen
- 1 j 13 h
- PR mergées (30 j)
- 623
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de nextcloud/server
-
[Bug]: Axios Update NeededOuverte0. Needs triage 35-feedback bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
34-feedback
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: GET /js/../<anything> returns 500 (NotPermittedException from JsController::getJs) instead of 404Peut-être pris @lazerg l’a pris il y a 7 jours. Ouverte35-feedback
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: Dashboard widgets registered via OCA.Dashboard.register() sometimes never mount (spinner forever) – Vue 3 non-deep `callbacks` watcher racePeut-être pris @lazerg l’a pris il y a 7 jours. Ouverte35-feedback
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de nextcloud/server
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
sonata-project/SonataAdminBundle#8426 ·
Les mainteneurs répondent en général sous 1 jour
-
good first issue help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 90/100
erkamyaman/rust-anything#942 ·
Les mainteneurs répondent en général sous 1 jour
-
CPU core labels missing for Low-Power E-cores on hybrid Intel CPUs (Arrow Lake-H) — get_intel_core_types() ignores /sys/devices/cpu_lowpowerPeut-être pris @dgongut l’a pris aujourd’hui. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
Les mainteneurs répondent en général sous 1 jour