Remove dependent realisations#14247
Conversation
c03e01e to
d795f87
Compare
d795f87 to
15f3abb
Compare
This will allow us to more accurately test dropping support for dependent realisations, by separating the tests that should not change from the tests that should. I do that change in PR NixOS#14247, but even if for some reasons we don't end up doing this soon, I think it is still good to separate the test data this way so we have the option of doing that at some point.
78329ec to
2f799fe
Compare
|
🎉 All dependencies have been resolved ! |
fad08df to
5fed736
Compare
aed2570 to
8c3e710
Compare
|
🎉 All dependencies have been resolved ! |
85ed2a5 to
fecd798
Compare
There was a problem hiding this comment.
I need to figure out how the migration for this works. CC @edolstra, do you know?
fecd798 to
0c33c8d
Compare
6900a7f to
3986922
Compare
3986922 to
809bafb
Compare
src/libstore/local-store.cc
Outdated
| throw Error( | ||
| "Migrating the database schema for the '%s' experimental feature is not yet supported.\n\n" | ||
| "Either downgrade Nix to a version that supports the old schema, " | ||
| "or disable the '%s' experimental feature.\n\n" | ||
| "Note: Disabling the experimental feature will safely leave all existing data intact.", | ||
| showExperimentalFeature(Xp::CaDerivations), | ||
| showExperimentalFeature(Xp::CaDerivations)); |
There was a problem hiding this comment.
This is the temporary so I can make progress on this stuff. When I am done and we have something that looks stable, we can then think about how to write this migration.
There was a problem hiding this comment.
That's not a great migration. I changed it to this instead:
From 9366ff4c02275d2d1bf35cd27d94ba5952071485 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Tue, 16 Dec 2025 19:53:12 +0100
Subject: [PATCH] local-store: better migration for RealisationsRefs removal
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The previous commit removed usage of the RealisationsRefs table but
threw an error for existing databases with CA derivations enabled,
blocking deployment entirely.
Instead of erroring, keep the old table around for backwards
compatibility with older Nix versions that may still share the
database. They will continue to populate it while new Nix simply
ignores it. This allows mixed-version deployments during upgrades.
Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
---
src/libstore/local-store.cc | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 080b454b6..df6d5cc7d 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -598,14 +598,15 @@ void LocalStore::upgradeDBSchema(State & state)
"20251013-remove-realisations-refs",
});
} else if (!schemaMigrations.contains("20251013-remove-realisations-refs")) {
- /* CA drvs previously enabled with old schema. */
- throw Error(
- "Migrating the database schema for the '%s' experimental feature is not yet supported.\n\n"
- "Either downgrade Nix to a version that supports the old schema, "
- "or disable the '%s' experimental feature.\n\n"
- "Note: Disabling the experimental feature will safely leave all existing data intact.",
- showExperimentalFeature(Xp::CaDerivations),
- showExperimentalFeature(Xp::CaDerivations));
+ /* CA drvs previously enabled with old schema. The new code no
+ longer uses the RealisationsRefs table, but we keep it around
+ for backwards compatibility with older Nix versions that may
+ still share this database. They will continue to populate it,
+ but we simply ignore it. */
+ debug("executing Nix database schema migration '%s'...", "20251013-remove-realisations-refs");
+
+ SQLiteTxn txn(state.db);
+ commitAndMarkMigrations(txn, {"20251013-remove-realisations-refs"});
}
}
}
--
2.50.1
Otherwise I wouldn't be able to upgrade at all. But I am wondering, why can we not keep the migration linear and just ignore the fact that we have a few empty tables in the schema? It would help when people upgrade/downgrade Nix versions.
There was a problem hiding this comment.
I was worried about the foreign keys, but I guess the on-delete cascade will help with that?
There was a problem hiding this comment.
As @Mic92 and I discussed, there is no more schema change at all.
|
🎉 All dependencies have been resolved ! |
809bafb to
7e34eea
Compare
| /** | ||
| * Execute a SQL statement. The string must be null-terminated. | ||
| */ | ||
| void exec(const char * stmt); | ||
|
|
||
| void exec(const std::string & stmt) | ||
| { | ||
| exec(stmt.c_str()); | ||
| } |
There was a problem hiding this comment.
Seems like some leftover thing?
This progress on NixOS#11896. It introduces some issues temporarily which will be fixed when NixOS#11928 is fixed. The SQL tables are left in place because there is no point inducing a migration now, when we will be immediately landing more changes after this that also require schema changes. They will simply be ignored by in this commit, and so all data will be preserved.
| std::vector<const Realisation *> realisations; | ||
| for (auto & path : paths) { | ||
| storePaths.insert(path.path()); | ||
| if (auto * realisation = std::get_if<Realisation>(&path.raw)) { | ||
| experimentalFeatureSettings.require(Xp::CaDerivations); | ||
| toplevelRealisations.insert(*realisation); | ||
| realisations.push_back(realisation); |
There was a problem hiding this comment.
Is this some kind of optimisation? We can split this out right?
There was a problem hiding this comment.
Discussed 1-1, is because I get rid of the closure method because we didn't really need it any more. This is just some inlined remnants of it.
7e34eea to
4a5d960
Compare
…isations Remove dependent realisations
Motivation
This progress on #11896. It introduces some issues temporarily which will be fixed when #11928 is fixed.
Context
The SQL tables are left in place because there is no point inducing a migration now, when we will be immediately landing more changes after this that also require schema changes. They will simply be ignored by in this commit, and so all data will be preserved.
Depends on #14465
Depends on #14425
Depends on #13942
Depends on #14793
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.