Race-condition in beforeCurrent hook
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- postgresql, typescript
Direzione di ricerca
Inizia tracciando l’hook beforeCurrent e il modo in cui watch gestisce più salvataggi di file quasi simultanei; l’issue non fornisce alcun file sorgente né la posizione di un test. Riproduci il problema con l’hook pg_dump-beforeCurrent e restoreCurrentData.sql in afterCurrent, modificando più file contemporaneamente. Il lavoro è completo quando l’esecuzione dell’hook è serializzata e il dump contiene costantemente i dati precedenti alla riesecuzione delle migrazioni.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
I use pg_dump to save data from tables, that are currently under development, and sometimes, pg_dump yields no data, sometimes it does, although there was data, before the current migrations were re-deployed.
Steps to reproduce
My hook in beforeCurrent:
(I use -T committed_table to only export data from tables, that will be destroyed and recreated.)
{
"_": "command",
"command": "pg_dump \"$GM_DBURL\" --data-only --schema app_public -T app_public.users -T app_public.user_emails -T app_public.user_authentications -T app_public.organizations -T app_public.organization_memberships -T app_public.organization_invitations --column-inserts --no-comments --rows-per-insert=1000 --file migrations/restoreCurrentData.sql"
}
The corresponding hook in afterCurrent
{
"_": "sql",
"file": "restoreCurrentData.sql",
"shadow": false
}
Expected results
restoreCurrentData.sql should always contain the data that was present, before the current migrations were about to re-run.
Actual results
restoreCurrentData.sql is sometimes empty, most often, when I changed multiple files at once. (Even if using save all in VSCode.) It happens less frequent, if I change my files one after another.
Additional context
Our conversation on Discord:
timostolz - at 2023-06-21 08:38:00+00:00
If I have "beforeCurrent" hooks in graphile-migrate, will they run synchronously, and will their end state be awaited, before the current migrations are deployed?
timostolz
I use pg_dump to save data from tables, that are currently under development, and sometimes, pg_dump yields no data, sometimes it does, although there was data, before the current migrations were re-deployed. However, if the current migrations and pg_dump run at the same time, a race-condition could explain this problem. Under this assumption, the tables could be dropped before pg_dump begins to export the data, finally leading to an empty result.
Benjie
Please file an issue and I’ll look into it. They should but I wonder if watch can trigger twice concurrently
timostolz
Ahh, up to now, I thought it happens completely at random. But as you come up with triggering twice: Most often, it happens, if I change two or more files at once. (Although I use the "Save all" command in VSCode to save them nearly at the same time.)
Benjie
Yeah it makes sense I’d forget to add a queue there especially given the SQL will queue automatically due to transactions, so without a beforeCurrent I wouldn’t notice the issue
Also hard to reproduce because everything is so fast, unless you’re using something like save all
- Lingua principale
- TypeScript
- Stelle
- 836
- Fork
- 71
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di graphile/migrate
-
Partition migrations folderAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
🐛 bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
Tutte le issue di graphile/migrate
Issue simili
-
foreground-up-signals-live: delivery-repair cell expects a spawn suggestion status no longer printsApertabug triage:owned
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
e2e-failure ready-to-code
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
redhat-developer/rhdh-plugin-export-overlays#4905 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
directus/directus#28558 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
review: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
1lck/Lithe-IDEA#2432 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
cloudflare/workers-sdk#17189 ·
I maintainer di solito rispondono entro 1 giorno