Migrations commit schema changes even when history updates fail
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 66/100
Research direction
Start with src/core/db/migrate.c, especially migrate_exec_sql() and the up/down paths at the cited lines; trace where the migration transaction ends and where _cwist_migrations is updated. Add failure-injection tests for failed history inserts and deletes, then run the migration tests. Done means a failed history write returns an error and rolls back both the schema change and its history update.
Written by the indexing model from the issue text.
Description
Affected: dev at bb2a33946.
migrate_exec_sql() commits each up/down migration before the caller updates _cwist_migrations (src/core/db/migrate.c:40-67, src/core/db/migrate.c:142-159, and src/core/db/migrate.c:210-225). The history sqlite3_step() result is ignored and the history write is outside the migration transaction.
Reproduction:
- Create a trigger that raises
FAILon every insert into_cwist_migrations. - Run an up migration that creates
items. - Observe
cwist_migrate_up()returnCWIST_MIGRATE_OK,itemsexists, butcwist_migrate_version()returns 0.
Observed: migration: rc=0 version=0 items_table=1.
A later run can reapply an already-committed migration, causing errors or destructive schema changes. Down migrations have the inverse inconsistency when the history delete fails.
Expected: execute the schema change and its history insert/delete in one transaction, check every SQLite result, and roll back both on any failure. Add failure-injection tests for up and down history writes.
- Dominant language
- C
- Stars
- 16
- Forks
- 7
- Avg merge
- 5h 39m
- Merged PRs (30d)
- 185
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from c4punks/CWIST
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 1-2 days Newbie friendliness 57/100
Maintainers usually reply within 1 day
-
bug good first issue
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 65/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
ly05010419/MacNativeGames#1796 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jniebuhr/gaggimate#1009 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Bug :bug:
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sonic-net/sonic-buildimage#30563 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
llvm/offload-test-suite#1698 ·
Maintainers usually reply within 1 day