How to re-attach a Stardog database?


(Eron Wright) #1

I have a database (mydatabase) that was created on a dedicated, persistent volume (in a public cloud environment). e.g. created in $STARDOG_HOME/mydatabase where the data disk was mounted. Meanwhile, the system database was lost because it was backed by an ephemeral disk. I figured that I could simply recreate the database and that the existing data would survive; it did not.

Not to worry, it was a test environment (Stardog 5.3.2), but I’d like to know if, in concept, it is possible to re-attach a database. Here’s the error that was produced:

ERROR 2018-08-05 18:16:12,949 [Stardog.Executor-17] com.complexible.stardog.dht.dictionary.HashDictionary:compareSizes(352): Dictionary corruption 0 != 34767
WARN  2018-08-05 18:16:13,018 [Stardog.Executor-17] com.complexible.stardog.dht.dictionary.HashDictionary:<init>(271): Dictionary is corrupted, will try to repair automatically
java.io.IOException: Dictionary file is corrupt, rebuild the database
	at com.complexible.stardog.dht.dictionary.HashDictionary.compareSizes(HashDictionary.java:353) ~[stardog-5.3.2.jar:?]
	at com.complexible.stardog.dht.dictionary.HashDictionary.<init>(HashDictionary.java:263) ~[stardog-5.3.2.jar:?]
	at com.complexible.stardog.dht.dictionary.HashDictionary$Builder.build(HashDictionary.java:160) ~[stardog-5.3.2.jar:?]
	at com.complexible.stardog.dht.dictionary.HashDictionary$Builder.build(HashDictionary.java:114) ~[stardog-5.3.2.jar:?]
	at com.complexible.stardog.index.dictionary.InliningMappingDictionary$Builder.build(InliningMappingDictionary.java:53) ~[stardog-5.3.2.jar:?]
...

Thanks for insight!


(stephen) #2

In theory, you can perform a stardog-admin db create command on the new (empty) home, shut down your server, copy the old data dir into the new home, and restart, and the database should be back


(Eron Wright) #3

Thanks Stephen, this suggests that a stardog-admin db attach command would be easy to build.


(Pavel Klinov) #4

Right, except this will not work with the new storage backend coming in Stardog 6 (currently in the alpha stage) because database data won’t be in a separate directory any more. The principled way to preserve (and restore) data is backups.

Best,
Pavel