There are occasions when one of more of the indexes on the Virtuoso RDF QUAD Store table become corrupted.
In such cases it is important to repair these indexes to prevent query failures or incorrect data being returned.
Check the counts on all the indexes on the RDF_QUAD table by running the following queries:
select count (*) from rdf_quad table option (index rdf_quad); select count (*) from rdf_quad table option (index rdf_quad_pogs); select count (*) from rdf_quad table option (index rdf_quad_sp); select count (*) from rdf_quad table option (index rdf_quad_gs); select count (*) from rdf_quad table option (index rdf_quad_op);
If the counts differ then there one or more of the indexes is corrupt and need to be repaired.
Check the primary key on the RDF_QUAD table is not broken by running the command:
select count (s), count (p ), count (o ), count (g ) from rdf_quad table option (index rdf_quad, check);
The counts of s, p, o, g should all be the same.
Run a database in integrity check to check the state of the database with the command:
Failure of this command to complete is another indication of the database having some form of corruption, requiring a
+backup-dump of the database with the command:
virtuoso-iodbc-t +configfile virtuoso.ini +backup-dump
If the Virtuoso log output of this command indicates a Broken Index as below:
08:20:27 Database dump started 08:20:27 Checkpoint finished, log reused 08:20:27 Dumping the schema tables 08:20:27 Dumping the registry 08:20:27 Dumping the schema done 09:03:02 Broken index RDF_QUAD_POGS 09:03:02 GPF: colsearch.c:1753 less ces in seg than indicated in leaf col ref GPF: colsearch.c:1753 less ces in seg than indicated in leaf col ref Segmentation fault (core dumped)
Then that index and any others (comma delimited) need to be removed from the
+backup-dump by adding them to the
parameter in the [Parameters] section of the Virtuoso config file (virtuoso.ini):
[Parameters] BackupIgnoreKeys = RDF_QUAD_POGS
+backup-dump which should then complete as which time the database can be restored with the
virtuoso-iodbc-t +configfile virtuoso.ini +restore-crash-dump
The missing index will then have to be recreated as detailed in the RDF Performance Tuning guide, thus is the case of the RDF_QUAD_POGS index the command would be:
CREATE COLUMN INDEX RDF_QUAD_POGS ON DB.DBA.RDF_QUAD (P, O, G, S) PARTITION (O varchar (-1, 0hexffff));
Finally rerun the database integrity check above and check the index counts are now all the same, in which case the indexes are repaired and the database is ready for use again.