fix DB-locked error in egg_update?
This commit is contained in:
parent
81bbdd1aef
commit
8ed58917ff
6
www/extern/egg/EGGDatabase.php
vendored
6
www/extern/egg/EGGDatabase.php
vendored
@ -62,7 +62,7 @@ class EGGDatabase
|
||||
|
||||
public function abortTransactionIfExists()
|
||||
{
|
||||
if ($this->pdo !== null) $this->pdo->rollBack();
|
||||
if ($this->pdo !== null && $this->pdo->inTransaction()) $this->pdo->rollBack();
|
||||
}
|
||||
|
||||
private function init()
|
||||
@ -222,7 +222,7 @@ class EGGDatabase
|
||||
* @param Commit[] $commits
|
||||
*/
|
||||
public function insertNewCommits(string $source, Repository $repo, Branch $branch, array $commits) {
|
||||
$this->logger->proclog("Inserted " . count($commits) . " (new) commits into [" . $source . "|" . $repo->Name . "|" . $branch->Name . "]");
|
||||
$this->logger->proclog("Inserting " . count($commits) . " (new) commits into [" . $source . "|" . $repo->Name . "|" . $branch->Name . "]");
|
||||
|
||||
foreach ($commits as $commit)
|
||||
{
|
||||
@ -261,6 +261,8 @@ class EGGDatabase
|
||||
* @param string $head
|
||||
*/
|
||||
public function setBranchHead(Branch $branch, string $head) {
|
||||
$this->logger->proclog("Set HEAD of branch [" . $branch->Repo->Source . "|" . $branch->Repo->Name . "|" . $branch->Name . "] to {".substr($head, 0, 8)."}");
|
||||
|
||||
$this->sql_exec_prep("UPDATE branches SET head = :head WHERE id = :id",
|
||||
[
|
||||
[":id", $branch->ID, PDO::PARAM_INT],
|
||||
|
18
www/extern/egg/RemoteSource.php
vendored
18
www/extern/egg/RemoteSource.php
vendored
@ -51,9 +51,7 @@ abstract class StandardGitConnection implements IRemoteSource
|
||||
{
|
||||
$this->preUpdate();
|
||||
|
||||
$db->beginTransaction();
|
||||
$repos = $this->listAndUpdateRepositories($db);
|
||||
$db->commitTransaction();
|
||||
|
||||
$anyChanged = false;
|
||||
|
||||
@ -91,19 +89,21 @@ abstract class StandardGitConnection implements IRemoteSource
|
||||
if ($repo_changed) $db->setChangeDateOnRepository($repo);
|
||||
if ($repo_changed) $anyChanged = true;
|
||||
}
|
||||
|
||||
$this->logger->proclog("Committing SQL-transaction for [" . $this->name . "|" . $repo->Name . "]");
|
||||
$db->commitTransaction();
|
||||
}
|
||||
|
||||
if ($anyChanged)
|
||||
{
|
||||
$db->beginTransaction();
|
||||
$this->logger->proclog("Deleting dangling commits...");
|
||||
|
||||
$db->deleteDanglingCommitdata($this->name);
|
||||
$db->commitTransaction();
|
||||
}
|
||||
|
||||
$db->beginTransaction();
|
||||
$this->postUpdate();
|
||||
$db->commitTransaction();
|
||||
|
||||
$this->logger->proclog("Finished [" . $this->name . "]");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -271,9 +271,11 @@ abstract class StandardGitConnection implements IRemoteSource
|
||||
$next_sha = [ $branch->HeadFromAPI ];
|
||||
$visited = array_map(function(Commit $m):string{return $m->Hash;}, $db->getCommits($branch));
|
||||
|
||||
$this->logger->proclog("Query commit for [" . $this->name . "|" . $repo->Name . "|" . $branch->Name . "] (initial @ {" . substr($next_sha[0], 0, 8) . "})");
|
||||
|
||||
$json = $this->queryCommits($repo->Name, $branch->Name, $next_sha[0]);
|
||||
|
||||
for (;;)
|
||||
for ($pg=2;;$pg++)
|
||||
{
|
||||
foreach ($json as $result_commit)
|
||||
{
|
||||
@ -336,6 +338,8 @@ abstract class StandardGitConnection implements IRemoteSource
|
||||
$next_sha = array_values($next_sha); // fix numeric keys
|
||||
if (count($next_sha) === 0) break;
|
||||
|
||||
$this->logger->proclog("Query commit for [" . $this->name . "|" . $repo->Name . "|" . $branch->Name . "] (" . $pg . " @ {" . substr($next_sha[0], 0, 8) . "})");
|
||||
|
||||
$json = $this->queryCommits($repo->Name, $branch->Name, $next_sha[0]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user