Skip to content
This repository was archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
ISAICP-6242: Try to run 3 times before failing the query.
Browse files Browse the repository at this point in the history
  • Loading branch information
idimopoulos committed Apr 5, 2021
1 parent 83dc458 commit 3c09621
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,25 @@ class Connection extends BaseConnection implements ConnectionInterface {
* {@inheritdoc}
*/
public function query(string $query, array $args = [], array $options = []): Result {
try {
return parent::query($query);
}
catch (SparqlQueryException $e) {
// During a Virtuoso checkpoint, the server locks down, causing HTTP
// requests on the SPARQL endpoint to fail with a 404 response. We wait a
// reasonable amount of time and then we retry one more time.
// @see http://docs.openlinksw.com/virtuoso/checkpoint/
sleep(5);
return parent::query($query);
}
$attempts = 2;
do {
$success = TRUE;
try {
return parent::query($query);
}
catch (SparqlQueryException $e) {
// During a Virtuoso checkpoint, the server locks down, causing HTTP
// requests on the SPARQL endpoint to fail with a 404 response. We wait
// a reasonable amount of time and then we retry one more time.
// @see http://docs.openlinksw.com/virtuoso/checkpoint/
sleep(5);
if ($attempts === 0) {
throw new \Exception($e->getMessage());
}
$attempts--;
$success = FALSE;
}
} while (!$success);
}

/**
Expand Down

0 comments on commit 3c09621

Please sign in to comment.