@@ -142,11 +142,22 @@ private void openDatabase(Options dbOptions) throws IOException {
142142 if (!Files .isSymbolicLink (dbPath .getParent ())) {
143143 Files .createDirectories (dbPath .getParent ());
144144 }
145- database = factory .open (dbPath .toFile (), dbOptions );
146- if (!this .getDBName ().startsWith ("checkpoint" )) {
147- logger .info ("DB {} open success with writeBufferSize {} M, cacheSize {} M, maxOpenFiles {}." ,
148- this .getDBName (), dbOptions .writeBufferSize () / 1024 / 1024 ,
149- dbOptions .cacheSize () / 1024 / 1024 , dbOptions .maxOpenFiles ());
145+ try {
146+ database = factory .open (dbPath .toFile (), dbOptions );
147+ if (!this .getDBName ().startsWith ("checkpoint" )) {
148+ logger
149+ .info ("DB {} open success with writeBufferSize {} M, cacheSize {} M, maxOpenFiles {}." ,
150+ this .getDBName (), dbOptions .writeBufferSize () / 1024 / 1024 ,
151+ dbOptions .cacheSize () / 1024 / 1024 , dbOptions .maxOpenFiles ());
152+ }
153+ } catch (IOException e ) {
154+ if (e .getMessage ().contains ("Corruption:" )) {
155+ logger .error ("Database {} corrupted, please delete database directory({}) and restart." ,
156+ dataBaseName , parentPath , e );
157+ } else {
158+ logger .error ("Open Database {} failed" , dataBaseName , e );
159+ }
160+ System .exit (1 );
150161 }
151162 }
152163
0 commit comments