-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database upgrades are not atomic with schema number bump #1954
Comments
Ping @edolstra, this seems very bad |
@NixOS/nix-core FYI |
I'm waiting to re-install nixos from a live usb to help this get fixed, so please let me know of any missing information you need, thanks :) |
@nico202 What version of nix did you have before? |
@shlevy ehm, no idea how to find out. I've always been on latest unstable, and run sudo nix-collect-garbage -d before upgrading. This is what I have in /nix/store now:
|
@nico202 Can you check |
Ah, if you gc'd before upgrading then you should still have the generation right before the upgrade too. |
Ah I bet I know what it is. The database migrations aren't atomic. Let me get you a command to verify... |
Can you do:
|
I think we need to store the schema version in the DB to avoid this. |
I'd like to, but I don't have sqlite3 installed .-. I have another nixos machine, is there a simple way to copy all the dependencies and install it manually from there? |
@nico202 Not sure what you mean by copy all the dependencies, but you can just copy db.sqlite |
@nico202 Note that I think this will be resolvable without re-installing. Just have to verify my guess. |
@shlevy ahah yeah I was thinking the other way round (moving sqlite3 to this machine XD) I'll copy the file and try. |
CREATE TABLE ValidPaths (
id integer primary key autoincrement not null,
path text unique not null,
hash text not null,
registrationTime integer not null,
deriver text,
narSize integer
, ultimate integer, sigs text, ca text);
CREATE TRIGGER DeleteSelfRefs before delete on ValidPaths
begin
delete from Refs where referrer = old.id and reference = old.id;
end; |
OK, great. So what happened here is that you got a schema upgrade saved in the DB but the schema version file was not updated (due to process getting interrupted, reboot, whatever). The quick workaround is |
Wow, that was easy, thanks! |
Do you want to keep this open until you push a fix or can I close it? |
I'll keep it open if you don't mind. |
Sure no problem, thanks a lot :) |
Before this, there was a gap between the database update and changes to the schema version file, leading to NixOS#1954. Now database changes and schema bumps happen in a single transaction. To avoid gratuitous backwards incompatibility, we still write 10 to the old version file, and will write 11 on the next schema bump. We won't write 12 to it unless we're moving away from storing the schema in the database. Fixes NixOS#1954.
Before this, there was a gap between the database update and changes to the schema version file, leading to NixOS#1954. Now database changes and schema bumps happen in a single transaction. Fixes NixOS#1954.
This bug just hit me after an NixOS upgrade 17.09 -> 18.03. I updated the channel
Here the stuff asked from above:
NOTE: Schema looks different than the one above and also different to another NixOS 18.03 I own. But the setting |
See #1956 |
I marked this as stale due to inactivity. → More info |
Report
I'm on NixOS unstable. After nixos-rebuild switch'ing to the latest unstable, (upgrade from the unstable of last week), nix does not work anymore, neither as root nor as user.
The error message:
The same error if run with sudo or after sudo -s.
Details
nix-info as user (those don's seems to be channels, see the output of nix-channel --list below):
"x86_64-linux"
Linux 4.14.24, NixOS, 18.03pre130932.cc4677c36ee (Impala)
no
yes
nix-env (Nix) 2.0pre5968_a6c0b773
"nixos-18.03pre129076.831ef4756e3, telegram-cli-2016-03-23, machine-0.9.0, gitlab-runner-1.10.4, california-0.4.0, entr-3.6, tmuxp-1.2.2, keybase-20170209.17b641d, kbfs-20170209.d1db463, non-2016-12-07, go-sct-20160529-1d6b5e0, freecad-0.16, antimony-0.9.2, librecad-2.1.3, lemonbar-xft-unstable-2016-02-17, pencil-2.0.21, python3.5-qnotero-1.0.0, ruby-2.3.3, gimp-2.8.20, chromium-56.0.2924.87, nix-repl-1.11.7-2016-02-28, gparted-0.26.1, screen-4.5.1, vmpk-0.5.1, a2jmidid-8, platformio, teensyduino-1.6.12, teensy-loader-cli-2.1, blender-2.78c, unetbootin-613, mediainfo-0.7.91, xournal-0.4.8, zip-3.0, graphviz-2.40.1, ffmpeg-3.2.4, vlc-2.2.4, okular-16.12.2, pdfmod-0.9.1, green-pdfviewer-nightly-2014-04-22, android-sdk-25.2.3, android-studio-2.2.3.0, zathura-with-plugins-0.3.7, openjdk-8u121b13, android-ndk-r10e, virtualbox-5.1.14, R-3.3.2-wrapper, aspell-dict-en-2016.06.26-0"
"nixpkgs-18.03pre117013.aebdc892d6"
"nixos-18.03pre130932.cc4677c36ee"
/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
nix-info as root:
error: executing SQLite statement 'alter table ValidPaths add column ultimate integer': SQL logic error (in '/nix/var/nix/db/db.sqlite')
0
Linux 4.14.24, NixOS, 18.03pre130932.cc4677c36ee (Impala)
no
yes
error: executing SQLite statement 'alter table ValidPaths add column ultimate integer': SQL logic error (in '/nix/var/nix/db/db.sqlite')
0
error: executing SQLite statement 'alter table ValidPaths add column ultimate integer': SQL logic error (in '/nix/var/nix/db/db.sqlite')
Both as user and root:
nix-channel --list
nixos https://nixos.org/channels/nixos-unstable
cat /etc/nix/nix.conf
nix-store --verify --check-contents --readonly-mode
root:
user:
The text was updated successfully, but these errors were encountered: