Problem/Motivation
In the \Drupal\sparql_entity_storage\SparqlEntityStorage::doSave
there is the following code:
if (!$entity->isNew()) {
$this->deleteBeforeInsert($id, $graph_uri);
}
try {
$this->insert($graph, $graph_uri);
return $entity->isNew() ? SAVED_NEW : SAVED_UPDATED;
}
The ::insert
contains the serialization sequence of the strings. EasyRdf library is quite slow in encoding the strings and can result in a failure. This means that if there is a failure in the insert, the data are lost from the database since Sparql/Virtuoso does not support transactions.
Proposed resolution
Replace the code in ::insert
to perform a DELETE .. INSERT
if the entity is not new which does not perform any changes if any part of the query fails.
Note that the DELETE..INSERT
contains a WHERE
clause and has to match entries to delete in order to insert. That means, that in case the entity is new, it should be a simple INSERT
query because otherwise, no matches will occur from the WHERE
clause and there will be no action performed.
Move the query AFTER the serialization of the data.
Issue fork sparql_entity_storage-3349309
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
claudiu.cristeaComment #4
claudiu.cristeaComment #6
idimopoulos CreditAttribution: idimopoulos for European Commission and European Union Institutions, Agencies and Bodies commented