forked from lix-project/lix
* Split the database upgrade into multiple transactions to prevent
Berkeley DB from running out of locks.
This commit is contained in:
parent
11a8dc76d6
commit
b1eed6b586
|
@ -1012,6 +1012,8 @@ static void upgradeStore07()
|
||||||
(and properly spelled) `referrer' table. */
|
(and properly spelled) `referrer' table. */
|
||||||
static void upgradeStore09()
|
static void upgradeStore09()
|
||||||
{
|
{
|
||||||
|
/* !!! we should disallow concurrent upgrades */
|
||||||
|
|
||||||
printMsg(lvlError, "upgrading Nix store to new schema (this may take a while)...");
|
printMsg(lvlError, "upgrading Nix store to new schema (this may take a while)...");
|
||||||
|
|
||||||
if (!pathExists(nixDBPath + "/referers")) return;
|
if (!pathExists(nixDBPath + "/referers")) return;
|
||||||
|
@ -1024,6 +1026,8 @@ static void upgradeStore09()
|
||||||
|
|
||||||
Paths referersKeys;
|
Paths referersKeys;
|
||||||
nixDB.enumTable(txn, dbReferers, referersKeys);
|
nixDB.enumTable(txn, dbReferers, referersKeys);
|
||||||
|
|
||||||
|
int n = 0;
|
||||||
for (Paths::iterator i = referersKeys.begin();
|
for (Paths::iterator i = referersKeys.begin();
|
||||||
i != referersKeys.end(); ++i)
|
i != referersKeys.end(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -1032,12 +1036,17 @@ static void upgradeStore09()
|
||||||
for (Paths::iterator j = referers.begin();
|
for (Paths::iterator j = referers.begin();
|
||||||
j != referers.end(); ++j)
|
j != referers.end(); ++j)
|
||||||
nixDB.setString(txn, dbReferrers, addPrefix(*i, *j), "");
|
nixDB.setString(txn, dbReferrers, addPrefix(*i, *j), "");
|
||||||
|
if (++n % 1000 == 0) {
|
||||||
|
txn.commit();
|
||||||
|
txn.begin(nixDB);
|
||||||
|
cerr << "|";
|
||||||
|
}
|
||||||
cerr << ".";
|
cerr << ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
cerr << "\n";
|
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
|
cerr << "\n";
|
||||||
|
|
||||||
nixDB.closeTable(dbReferers);
|
nixDB.closeTable(dbReferers);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue