Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nora Puchreiner
Nix
Commits
0abe1856
Commit
0abe1856
authored
21 years ago
by
Eelco Dolstra
Browse files
Options
Downloads
Patches
Plain Diff
* `nix --verify': check and repair reverse mapping for successors.
parent
d3d5e778
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/store.cc
+32
-88
32 additions, 88 deletions
src/store.cc
src/store.hh
+1
-1
1 addition, 1 deletion
src/store.hh
with
33 additions
and
89 deletions
src/store.cc
+
32
−
88
View file @
0abe1856
...
...
@@ -82,25 +82,25 @@ void copyPath(const Path & src, const Path & dst)
void
registerSuccessor
(
const
Transaction
&
txn
,
const
Path
&
p
ath
1
,
const
Path
&
p
ath
2
)
const
Path
&
srcP
ath
,
const
Path
&
sucP
ath
)
{
Path
known
;
if
(
nixDB
.
queryString
(
txn
,
dbSuccessors
,
p
ath
1
,
known
)
&&
known
!=
p
ath
2
)
if
(
nixDB
.
queryString
(
txn
,
dbSuccessors
,
srcP
ath
,
known
)
&&
known
!=
sucP
ath
)
{
throw
Error
(
format
(
"the `impossible' happened: expression in path "
"`%1%' appears to have multiple successors "
"(known `%2%', new `%3%'"
)
%
p
ath
1
%
known
%
p
ath
2
);
%
srcP
ath
%
known
%
sucP
ath
);
}
Paths
revs
;
nixDB
.
queryStrings
(
txn
,
dbSuccessorsRev
,
p
ath
2
,
revs
);
revs
.
push_back
(
p
ath
1
);
nixDB
.
queryStrings
(
txn
,
dbSuccessorsRev
,
sucP
ath
,
revs
);
revs
.
push_back
(
srcP
ath
);
nixDB
.
setString
(
txn
,
dbSuccessors
,
p
ath
1
,
p
ath
2
);
nixDB
.
setStrings
(
txn
,
dbSuccessorsRev
,
p
ath
2
,
revs
);
nixDB
.
setString
(
txn
,
dbSuccessors
,
srcP
ath
,
sucP
ath
);
nixDB
.
setStrings
(
txn
,
dbSuccessorsRev
,
sucP
ath
,
revs
);
}
...
...
@@ -213,74 +213,22 @@ void verifyStore()
{
Transaction
txn
(
nixDB
);
/* !!! verify that the result is consistent */
#if 0
Strings paths;
nixDB.enumTable(txn, dbPath2Id, paths);
Paths
paths
;
nixDB
.
enumTable
(
txn
,
dbValidPaths
,
paths
);
for (
String
s::iterator i = paths.begin();
for
(
Path
s
::
iterator
i
=
paths
.
begin
();
i
!=
paths
.
end
();
i
++
)
{
bool erase = true;
string path = *i;
Path
path
=
*
i
;
if
(
!
pathExists
(
path
))
{
debug
(
format
(
"path `%1%' disappeared"
)
%
path
);
nixDB
.
delPair
(
txn
,
dbValidPaths
,
path
);
nixDB
.
delPair
(
txn
,
dbSuccessorsRev
,
path
);
nixDB
.
delPair
(
txn
,
dbSubstitutesRev
,
path
);
}
else {
string id;
if (!nixDB.queryString(txn, dbPath2Id, path, id)) abort();
Strings idPaths;
nixDB.queryStrings(txn, dbId2Paths, id, idPaths);
bool found = false;
for (Strings::iterator j = idPaths.begin();
j != idPaths.end(); j++)
if (path == *j) {
found = true;
break;
}
if (found)
erase = false;
else
/* !!! perhaps we should add path to idPaths? */
debug(format("reverse mapping for path `%1%' missing") % path);
}
if (erase) nixDB.delPair(txn, dbPath2Id, path);
}
Strings ids;
nixDB.enumTable(txn, dbId2Paths, ids);
for (Strings::iterator i = ids.begin();
i != ids.end(); i++)
{
FSId id = parseHash(*i);
Strings idPaths;
nixDB.queryStrings(txn, dbId2Paths, id, idPaths);
for (Strings::iterator j = idPaths.begin();
j != idPaths.end(); )
{
string id2;
if (!nixDB.queryString(txn, dbPath2Id, *j, id2) ||
id != parseHash(id2)) {
debug(format("erasing path `%1%' from mapping for id %2%")
% *j % (string) id);
j = idPaths.erase(j);
} else j++;
}
nixDB.setStrings(txn, dbId2Paths, id, idPaths);
}
#if 0
Strings subs;
nixDB.enumTable(txn, dbSubstitutes, subs);
...
...
@@ -308,31 +256,27 @@ void verifyStore()
nixDB.setStrings(txn, dbSubstitutes, srcId, subIds);
}
#endif
String
s sucs;
Path
s
sucs
;
nixDB
.
enumTable
(
txn
,
dbSuccessors
,
sucs
);
for (Strings::iterator i = sucs.begin();
i != sucs.end(); i++)
{
FSId id1 = parseHash(*i);
string id2;
if (!nixDB.queryString(txn, dbSuccessors, id1, id2)) abort();
Strings id2Paths;
nixDB.queryStrings(txn, dbId2Paths, id2, id2Paths);
if (id2Paths.size() == 0) {
Strings id2Subs;
nixDB.queryStrings(txn, dbSubstitutes, id2, id2Subs);
if (id2Subs.size() == 0) {
debug(format("successor %1% for %2% missing")
% id2 % (string) id1);
nixDB.delPair(txn, dbSuccessors, (string) id1);
}
for
(
Paths
::
iterator
i
=
sucs
.
begin
();
i
!=
sucs
.
end
();
i
++
)
{
Path
srcPath
=
*
i
;
Path
sucPath
;
if
(
!
nixDB
.
queryString
(
txn
,
dbSuccessors
,
srcPath
,
sucPath
))
abort
();
Paths
revs
;
nixDB
.
queryStrings
(
txn
,
dbSuccessorsRev
,
sucPath
,
revs
);
if
(
find
(
revs
.
begin
(),
revs
.
end
(),
srcPath
)
==
revs
.
end
())
{
debug
(
format
(
"reverse successor mapping from `%1%' to `%2%' missing"
)
%
srcPath
%
sucPath
);
revs
.
push_back
(
srcPath
);
nixDB
.
setStrings
(
txn
,
dbSuccessorsRev
,
sucPath
,
revs
);
}
}
#endif
txn
.
commit
();
}
This diff is collapsed.
Click to expand it.
src/store.hh
+
1
−
1
View file @
0abe1856
...
...
@@ -20,7 +20,7 @@ void copyPath(const Path & src, const Path & dst);
we do it in reverse order, we can get an obstructed build (since to
rebuild the successor, the outputs paths must not exist). */
void
registerSuccessor
(
const
Transaction
&
txn
,
const
Path
&
p
ath
1
,
const
Path
&
p
ath
2
);
const
Path
&
srcP
ath
,
const
Path
&
sucP
ath
);
/* Register a substitute. */
void
registerSubstitute
(
const
Path
&
srcPath
,
const
Path
&
subPath
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment