mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 00:06:16 +02:00
* Commit more often to prevent out-of-memory errors.
This commit is contained in:
parent
98df735b51
commit
3a99616968
3 changed files with 22 additions and 4 deletions
|
@ -33,11 +33,9 @@ Transaction::Transaction()
|
||||||
|
|
||||||
|
|
||||||
Transaction::Transaction(Database & db)
|
Transaction::Transaction(Database & db)
|
||||||
|
: txn(0)
|
||||||
{
|
{
|
||||||
db.requireEnv();
|
begin(db);
|
||||||
try {
|
|
||||||
db.env->txn_begin(0, &txn, 0);
|
|
||||||
} catch (DbException e) { rethrow(e); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,6 +45,16 @@ Transaction::~Transaction()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Transaction::begin(Database & db)
|
||||||
|
{
|
||||||
|
assert(txn == 0);
|
||||||
|
db.requireEnv();
|
||||||
|
try {
|
||||||
|
db.env->txn_begin(0, &txn, 0);
|
||||||
|
} catch (DbException e) { rethrow(e); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Transaction::commit()
|
void Transaction::commit()
|
||||||
{
|
{
|
||||||
if (!txn) throw Error("commit called on null transaction");
|
if (!txn) throw Error("commit called on null transaction");
|
||||||
|
|
|
@ -27,6 +27,7 @@ public:
|
||||||
Transaction(Database & _db);
|
Transaction(Database & _db);
|
||||||
~Transaction();
|
~Transaction();
|
||||||
|
|
||||||
|
void begin(Database & db);
|
||||||
void abort();
|
void abort();
|
||||||
void commit();
|
void commit();
|
||||||
|
|
||||||
|
|
|
@ -824,6 +824,7 @@ static void upgradeStore()
|
||||||
PathSet validPaths(validPaths2.begin(), validPaths2.end());
|
PathSet validPaths(validPaths2.begin(), validPaths2.end());
|
||||||
|
|
||||||
cerr << "hashing paths...";
|
cerr << "hashing paths...";
|
||||||
|
int n = 0;
|
||||||
for (PathSet::iterator i = validPaths.begin(); i != validPaths.end(); ++i) {
|
for (PathSet::iterator i = validPaths.begin(); i != validPaths.end(); ++i) {
|
||||||
checkInterrupt();
|
checkInterrupt();
|
||||||
string s;
|
string s;
|
||||||
|
@ -832,10 +833,18 @@ static void upgradeStore()
|
||||||
Hash hash = hashPath(htSHA256, *i);
|
Hash hash = hashPath(htSHA256, *i);
|
||||||
setHash(txn, *i, hash);
|
setHash(txn, *i, hash);
|
||||||
cerr << ".";
|
cerr << ".";
|
||||||
|
if (++n % 1000 == 0) {
|
||||||
|
txn.commit();
|
||||||
|
txn.begin(nixDB);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cerr << "\n";
|
cerr << "\n";
|
||||||
|
|
||||||
|
txn.commit();
|
||||||
|
|
||||||
|
txn.begin(nixDB);
|
||||||
|
|
||||||
cerr << "processing closures...";
|
cerr << "processing closures...";
|
||||||
for (PathSet::iterator i = validPaths.begin(); i != validPaths.end(); ++i) {
|
for (PathSet::iterator i = validPaths.begin(); i != validPaths.end(); ++i) {
|
||||||
checkInterrupt();
|
checkInterrupt();
|
||||||
|
|
Loading…
Reference in a new issue