Skip to content

Commit c448f06

Browse files
authored
Merge pull request #84 from nix-community/82-bug-v610-and-v611-dont-seem-to-work-with-v600-caches
Fix database merging logic
2 parents 57dad84 + fc908ed commit c448f06

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
lines changed

dist/restore-only/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84229,7 +84229,7 @@ drop table if exists DerivationOutputs;
8422984229

8423084230
create table DerivationOutputs
8423184231
(
84232-
drv integer not null,
84232+
drv integer not null, -- index of a path of a derivation in ValidPaths
8423384233
id text not null, -- symbolic output id, usually "out"
8423484234
path text not null,
8423584235
primary key (drv, id),
@@ -84344,14 +84344,11 @@ from DerivationOutputs1;
8434484344
-- Calculate updated derivation outputs for the second store
8434584345
-- =====
8434684346

84347-
-- drv | id | path
84347+
-- drv | id | path | drvPath
8434884348
drop view if exists DerivationIdPaths;
8434984349

84350-
84351-
-- TODO what is drv?
84352-
8435384350
create view DerivationIdPaths as
84354-
select drv, DerivationOutputs2.id, ValidPaths2_.path
84351+
select drv, DerivationOutputs2.id, DerivationOutputs2.path, ValidPaths2_.path as drvPath
8435584352
from DerivationOutputs2
8435684353
join (select id, path from ValidPaths2) as ValidPaths2_ on ValidPaths2_.id = drv;
8435784354

@@ -84360,9 +84357,9 @@ drop view if exists DerivationOutputs2Updated;
8436084357

8436184358
create view DerivationOutputs2Updated as
8436284359
select ValidPaths_.drvNew as drv, id, DerivationIdPaths_.path
84363-
from (select id, path from DerivationIdPaths) as DerivationIdPaths_
84360+
from (select id, path, drvPath from DerivationIdPaths) as DerivationIdPaths_
8436484361
join (select id as drvNew, path from ValidPaths) as ValidPaths_
84365-
on DerivationIdPaths_.path = ValidPaths_.path;
84362+
on DerivationIdPaths_.drvPath = ValidPaths_.path;
8436684363

8436784364
-- =====
8436884365
-- Insert updated derivation outputs from the second store
@@ -85015,6 +85012,7 @@ function restoreCache(key, ref) {
8501585012
yield (0, mergeStoreDatabases_1.mergeStoreDatabases)(tempDir, dbPath1, dbPath2, dbPath);
8501685013
utils.info(`Checking the store database.`);
8501785014
yield utils.run(`sqlite3 "${dbPath}" 'PRAGMA integrity_check;'`);
85015+
utils.info(`The store database is consistent.`);
8501885016
}
8501985017
return cacheKey;
8502085018
}

dist/restore/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84229,7 +84229,7 @@ drop table if exists DerivationOutputs;
8422984229

8423084230
create table DerivationOutputs
8423184231
(
84232-
drv integer not null,
84232+
drv integer not null, -- index of a path of a derivation in ValidPaths
8423384233
id text not null, -- symbolic output id, usually "out"
8423484234
path text not null,
8423584235
primary key (drv, id),
@@ -84344,14 +84344,11 @@ from DerivationOutputs1;
8434484344
-- Calculate updated derivation outputs for the second store
8434584345
-- =====
8434684346

84347-
-- drv | id | path
84347+
-- drv | id | path | drvPath
8434884348
drop view if exists DerivationIdPaths;
8434984349

84350-
84351-
-- TODO what is drv?
84352-
8435384350
create view DerivationIdPaths as
84354-
select drv, DerivationOutputs2.id, ValidPaths2_.path
84351+
select drv, DerivationOutputs2.id, DerivationOutputs2.path, ValidPaths2_.path as drvPath
8435584352
from DerivationOutputs2
8435684353
join (select id, path from ValidPaths2) as ValidPaths2_ on ValidPaths2_.id = drv;
8435784354

@@ -84360,9 +84357,9 @@ drop view if exists DerivationOutputs2Updated;
8436084357

8436184358
create view DerivationOutputs2Updated as
8436284359
select ValidPaths_.drvNew as drv, id, DerivationIdPaths_.path
84363-
from (select id, path from DerivationIdPaths) as DerivationIdPaths_
84360+
from (select id, path, drvPath from DerivationIdPaths) as DerivationIdPaths_
8436484361
join (select id as drvNew, path from ValidPaths) as ValidPaths_
84365-
on DerivationIdPaths_.path = ValidPaths_.path;
84362+
on DerivationIdPaths_.drvPath = ValidPaths_.path;
8436684363

8436784364
-- =====
8436884365
-- Insert updated derivation outputs from the second store
@@ -85015,6 +85012,7 @@ function restoreCache(key, ref) {
8501585012
yield (0, mergeStoreDatabases_1.mergeStoreDatabases)(tempDir, dbPath1, dbPath2, dbPath);
8501685013
utils.info(`Checking the store database.`);
8501785014
yield utils.run(`sqlite3 "${dbPath}" 'PRAGMA integrity_check;'`);
85015+
utils.info(`The store database is consistent.`);
8501885016
}
8501985017
return cacheKey;
8502085018
}

src/templates/merge.sql

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ drop table if exists DerivationOutputs;
8888

8989
create table DerivationOutputs
9090
(
91-
drv integer not null,
91+
drv integer not null, -- index of a path of a derivation in ValidPaths
9292
id text not null, -- symbolic output id, usually "out"
9393
path text not null,
9494
primary key (drv, id),
@@ -203,14 +203,11 @@ from DerivationOutputs1;
203203
-- Calculate updated derivation outputs for the second store
204204
-- =====
205205

206-
-- drv | id | path
206+
-- drv | id | path | drvPath
207207
drop view if exists DerivationIdPaths;
208208

209-
210-
-- TODO what is drv?
211-
212209
create view DerivationIdPaths as
213-
select drv, DerivationOutputs2.id, ValidPaths2_.path
210+
select drv, DerivationOutputs2.id, DerivationOutputs2.path, ValidPaths2_.path as drvPath
214211
from DerivationOutputs2
215212
join (select id, path from ValidPaths2) as ValidPaths2_ on ValidPaths2_.id = drv;
216213

@@ -219,9 +216,9 @@ drop view if exists DerivationOutputs2Updated;
219216

220217
create view DerivationOutputs2Updated as
221218
select ValidPaths_.drvNew as drv, id, DerivationIdPaths_.path
222-
from (select id, path from DerivationIdPaths) as DerivationIdPaths_
219+
from (select id, path, drvPath from DerivationIdPaths) as DerivationIdPaths_
223220
join (select id as drvNew, path from ValidPaths) as ValidPaths_
224-
on DerivationIdPaths_.path = ValidPaths_.path;
221+
on DerivationIdPaths_.drvPath = ValidPaths_.path;
225222

226223
-- =====
227224
-- Insert updated derivation outputs from the second store

src/utils/restore.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export async function restoreCache(key: string, ref?: string) {
4949
utils.info(`Checking the store database.`);
5050

5151
await utils.run(`sqlite3 "${dbPath}" 'PRAGMA integrity_check;'`);
52+
53+
utils.info(`The store database is consistent.`)
5254
}
5355

5456
return cacheKey;

0 commit comments

Comments
 (0)