ncbo / goo

Graph Oriented Objects (GOO) for Ruby. A RDF/SPARQL based ORM.
http://ncbo.github.io/goo/
Other
15 stars 6 forks source link

Random query failures with AllegroGraph v7.0.1 #107

Closed mdorf closed 3 years ago

mdorf commented 4 years ago

The query that fails is always the same (different graphs and ID filters, but the structure is identical), but the failures happen at random in various tests during the test suite execution. In each subsequent run, the error occurs inside a different test, where as the test that had previously failed runs fine.

This is the error:

Executing query failed:
the assertion (null (getf (db.agraph.cursor::cursor-properties db.agraph.sbqe::cursor) :is-ordered-cursor-for-distinct-variable)) failed.

This is the query:

SELECT DISTINCT ?id ( COUNT(DISTINCT ?children_agg_count) AS ?children_agg_count_projection ) 
FROM <http://data.bioontology.org/ontologies/OBSBRANCH/submissions/1> 
WHERE { ?id a <http://www.w3.org/2002/07/owl#Class> . 
       OPTIONAL { ?children_agg_count <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?id .  } 
       FILTER(?id = <http://www.w3.org/2004/02/skos/core#oboClass2OBS> || 
              ?id = <http://www.w3.org/2004/02/skos/core#oboClass1OBS> || 
              ?id = <http://www.geneontology.org/formats/oboInOwl#ObsoleteClass> || 
              ?id = <http://bioportal.bioontology.org/ontologies/msotes#class_7> || 
              ?id = <http://bioportal.bioontology.org/ontologies/msotes#class_5> || 
              ?id = <http://bioportal.bioontology.org/ontologies/msotes#class99> || 
              ?id = <http://bioportal.bioontology.org/ontologies/msotes#class98> || 
              ?id = <http://bioportal.bioontology.org/ontologies/msotes#class97> || 
              ?id = <http://bioportal.bioontology.org/ontologies/msotes#class6> || 
              ?id = <http://bioportal.bioontology.org/ontologies/msotes#class4> || 
              ?id = <http://bioportal.bioontology.org/ontologies/msotes#class3> || 
              ?id = <http://bioportal.bioontology.org/ontologies/msotes#class2> || 
              ?id = <http://bioportal.bioontology.org/ontologies/msotes#class1>) } 
GROUP BY ?id

This does NOT occur in AllegroGraph v6.4.1

mdorf commented 4 years ago

This shows the randomness of the test failures:

TestOntologySubmission#test_obo_part_of = 12.39 s = .
TestOntologySubmission#test_submission_parse_cno = 26.44 s = .
TestOntologySubmission#test_custom_obsolete_property = 3.92 s = .
TestOntologySubmission#test_discover_obo_in_owl_obsolete = 3.87 s = .
TestOntologySubmission#test_download_ontology_file = Thin web server (v1.7.2 codename Bachmanity)
Maximum connections set to 1024
Listening on localhost:57375, CTRL+C to stop
11.58 s = .
TestOntologySubmission#test_submission_diff_across_ontologies = 10.12 s = .
TestOntologySubmission#test_multiple_syn_multiple_predicate = 4.58 s = .
TestOntologySubmission#test_valid_ontology = 0.19 s = .
TestOntologySubmission#test_custom_obsolete_branch = QUERY FAILED: the assertion (null (getf (db.agraph.cursor::cursor-properties db.agraph.sbqe::cursor) :is-ordered-cursor-for-distinct-variable)) failed.
3.43 s = .
TestOntologySubmission#test_umls_metrics_file = 1.15 s = .
TestOntologySubmission#test_submission_parse_aero = 0.00 s = S
TestOntologySubmission#test_submission_parse_subfolders_zip = 4.43 s = .
TestOntologySubmission#test_index_properties = 5.17 s = .
TestOntologySubmission#test_process_submission_diff = 16.60 s = .
TestOntologySubmission#test_submission_parse_sbo = 10.44 s = .
TestOntologySubmission#test_semantic_types = 1.35 s = .
TestOntologySubmission#test_sanity_check_zip = 3.09 s = .
TestOntologySubmission#test_automaster_from_zip = 0.01 s = .
TestOntologySubmission#test_skos_ontology = 3.84 s = .
TestOntologySubmission#test_submission_parse_zip = 0 classes with no label
5.54 s = .
TestOntologySubmission#test_custom_property_generation = QUERY FAILED: the assertion (null (getf (db.agraph.cursor::cursor-properties db.agraph.sbqe::cursor) :is-ordered-cursor-for-distinct-variable)) failed.
3.28 s = .
TestOntologySubmission#test_submission_parse = 87.90 s = .
TestOntologySubmission#test_submission_metrics = 18.06 s = .
TestOntologySubmission#test_submission_root_classes = 3.86 s = .
TestOntologySubmission#test_duplicated_file_names = 0.29 s = .

VS

TestOntologySubmission#test_process_submission_archive = 83.45 s = .
TestOntologySubmission#test_submission_parse = 91.36 s = .
TestOntologySubmission#test_index_properties = 4.99 s = .
TestOntologySubmission#test_download_ontology_file = Thin web server (v1.7.2 codename Bachmanity)
Maximum connections set to 1024
Listening on localhost:60178, CTRL+C to stop
11.53 s = .
TestOntologySubmission#test_submission_parse_aero = 0.00 s = S
TestOntologySubmission#test_duplicated_file_names = 0.31 s = .
TestOntologySubmission#test_custom_obsolete_branch = 3.92 s = .
TestOntologySubmission#test_sanity_check_zip = 2.92 s = .
TestOntologySubmission#test_submission_root_classes = 6.60 s = .
TestOntologySubmission#test_submission_parse_sbo = 10.10 s = .
TestOntologySubmission#test_submission_diff_across_ontologies = 10.36 s = .
TestOntologySubmission#test_semantic_types = 1.28 s = .
TestOntologySubmission#test_custom_property_generation = QUERY FAILED: the assertion (null (getf (db.agraph.cursor::cursor-properties db.agraph.sbqe::cursor) :is-ordered-cursor-for-distinct-variable)) failed.
3.39 s = .
TestOntologySubmission#test_submission_parse_zip = 0 classes with no label
5.51 s = .
TestOntologySubmission#test_discover_obo_in_owl_obsolete = QUERY FAILED: the assertion (null (getf (db.agraph.cursor::cursor-properties db.agraph.sbqe::cursor) :is-ordered-cursor-for-distinct-variable)) failed.
3.44 s = .
TestOntologySubmission#test_automaster_from_zip = 0.01 s = .
TestOntologySubmission#test_multiple_syn_multiple_predicate = 4.75 s = .
TestOntologySubmission#test_umls_metrics_file = 1.27 s = .
TestOntologySubmission#test_custom_obsolete_property = QUERY FAILED: the assertion (null (getf (db.agraph.cursor::cursor-properties db.agraph.sbqe::cursor) :is-ordered-cursor-for-distinct-variable)) failed.
3.46 s = .
TestOntologySubmission#test_valid_ontology = 0.21 s = .
TestOntologySubmission#test_obo_part_of = 12.16 s = .
TestOntologySubmission#test_skos_ontology = 3.77 s = .
TestOntologySubmission#test_submission_parse_subfolders_zip = 4.61 s = .
TestOntologySubmission#test_process_submission_diff = 17.07 s = .
TestOntologySubmission#test_submission_metrics = 15.59 s = .
TestOntologySubmission#test_submission_parse_cno = 29.33 s = .
mdorf commented 4 years ago

Filed a support request with AllegroGrpah - [spr45071] Intermittent query failures in AllegroGraph v7.0.1. Received this response:

Thanks for the report. This indicates an error in the query engine. Could you please send the query execution log? Add this to the query:

PREFIX franzOption_logQuery:

and then copy what's written in agraph.log That will show how the query is planned and where the error comes from. Thanks.

Kind regards Willem

mdorf commented 4 years ago

The log is attached. agraph.log

mdorf commented 4 years ago

Further response from AllegroGraph:

Thanks for the report and the query log. We have traced it down and the next AG release, 7.0.2, will have a fix for this.

The reason the error does not occur every time you run the same SPARQL query, is that there are multiple possible query plans and only some of them lead to the bug. Which plan gets chosen depends on statistics (number of triples per predicate, and such).

As a workaround for now I recommend you create a patch file with the following name and contents:

filename: /lib/patches/patch-spr45071-bug26235.cl contents:

(in-package :db.agraph.cursor)

(excl:def-fwrapper make-null-spog-cursor-wrapper (&key order-by extended-triples-p) (declare (ignore order-by extended-triples-p)) (let ((ret (excl:call-next-fwrapper))) (setf (cursor-properties ret) nil) ret))

(excl:fwrap 'make-null-spog-cursor 'make-null-spog-cursor-wrapper 'make-null-spog-cursor-wrapper)

(compile 'make-null-spog-cursor-wrapper)

After creating this file and restarting AG the query should run fine all the time. Please remove this patch file when updating to AG 7.0.2. Thanks again for the report.

mdorf commented 4 years ago

I've confirmed that the patch fixes the issue. Ran the tests multiple times with no failures

mdorf commented 4 years ago

Currently testing AllegroGraph v7.0.2.rc2, which is supposed to address the issue.

mdorf commented 3 years ago

fixed in v7.0.2