Corrupt database detected. Unexpected files

Hi

After restarting Event Store 4 I got this error message:
[00001,01,14:20:28.615] Unhandled exception while starting application:
Corrupt database detected.
[00001,01,14:20:28.621] Corrupt database detected.
Unexpected files: /var/lib/eventstore/chunk-000001.000000, /var/lib/eventstore/chunk-000002.000000, /var/lib/eventstore/chunk-000003.000000, /var/lib/eventstore/chunk-000004.000000.
Corrupt database detected.

``

Do you know what may be the problem and how we can fix it?

Thanks
Julian

We would need to see the complete log, from the point to where the node has started up until it throws this exception.
For example the absense of the appropriate checkpoint files might cause this and this would be spotted by providing the logs.

Do the logs below help you any further?

I must say that we started the event store in a docker container on our development machine. After stopping and starting the container this problem occured.

exchange.eventstore | 2017-07-14T14:26:56.691406097Z [00001,01,14:26:56.652]
exchange.eventstore | 2017-07-14T14:26:56.691432610Z ES VERSION: 4.0.0.7 (HEAD/aa8cda89f70ddef785d4e673bf9a336bf88da59f, Thu, 23 Mar 2017 12:08:13 +0200)
exchange.eventstore | 2017-07-14T14:26:56.742324010Z [00001,01,14:26:56.687] OS: Linux (Unix 4.4.0.72)
exchange.eventstore | 2017-07-14T14:26:56.742342241Z [00001,01,14:26:56.706] RUNTIME: 4.6.2 (Stable 4.6.2.16/ac9e222) (64-bit)
exchange.eventstore | 2017-07-14T14:26:56.742346505Z [00001,01,14:26:56.707] GC: 2 GENERATIONS
exchange.eventstore | 2017-07-14T14:26:56.742349766Z [00001,01,14:26:56.707] LOGS: /var/log/eventstore
exchange.eventstore | 2017-07-14T14:26:56.742352898Z [00001,01,14:26:56.728] MODIFIED OPTIONS:
exchange.eventstore | 2017-07-14T14:26:56.742356013Z
exchange.eventstore | 2017-07-14T14:26:56.742358737Z INT IP: 0.0.0.0 (Config File)
exchange.eventstore | 2017-07-14T14:26:56.742361782Z EXT IP: 0.0.0.0 (Config File)
exchange.eventstore | 2017-07-14T14:26:56.742364674Z INT HTTP PREFIXES: http://:2112/ (Config File)
exchange.eventstore | 2017-07-14T14:26:56.742367687Z EXT HTTP PREFIXES: http://
:2113/ (Config File)
exchange.eventstore | 2017-07-14T14:26:56.742370636Z ADD INTERFACE PREFIXES: false (Config File)
exchange.eventstore | 2017-07-14T14:26:56.742373647Z RUN PROJECTIONS: All (Config File)
exchange.eventstore | 2017-07-14T14:26:56.742376588Z START STANDARD PROJECTIONS: true (Config File)
exchange.eventstore | 2017-07-14T14:26:56.742379373Z
exchange.eventstore | 2017-07-14T14:26:56.742382040Z DEFAULT OPTIONS:
exchange.eventstore | 2017-07-14T14:26:56.742389867Z
exchange.eventstore | 2017-07-14T14:26:56.742393272Z CONFIG: /etc/eventstore/eventstore.conf ()
exchange.eventstore | 2017-07-14T14:26:56.742396607Z HELP: False ()
exchange.eventstore | 2017-07-14T14:26:56.742399758Z VERSION: False ()
exchange.eventstore | 2017-07-14T14:26:56.742402809Z LOG: /var/log/eventstore ()
exchange.eventstore | 2017-07-14T14:26:56.742405926Z DEFINES: ()
exchange.eventstore | 2017-07-14T14:26:56.742409155Z WHAT IF: False ()
exchange.eventstore | 2017-07-14T14:26:56.742412135Z DISABLE HTTP CACHING: False ()
exchange.eventstore | 2017-07-14T14:26:56.742415147Z MONO MIN THREADPOOL SIZE: 10 ()
exchange.eventstore | 2017-07-14T14:26:56.742418237Z INT HTTP PORT: 2112 ()
exchange.eventstore | 2017-07-14T14:26:56.742421308Z EXT HTTP PORT: 2113 ()
exchange.eventstore | 2017-07-14T14:26:56.742424477Z INT TCP PORT: 1112 ()
exchange.eventstore | 2017-07-14T14:26:56.742427540Z INT SECURE TCP PORT: 0 ()
exchange.eventstore | 2017-07-14T14:26:56.742430470Z EXT TCP PORT: 1113 ()
exchange.eventstore | 2017-07-14T14:26:56.742433510Z EXT SECURE TCP PORT ADVERTISE AS: 0 ()
exchange.eventstore | 2017-07-14T14:26:56.742436583Z EXT SECURE TCP PORT: 0 ()
exchange.eventstore | 2017-07-14T14:26:56.742444820Z EXT IP ADVERTISE AS: ()
exchange.eventstore | 2017-07-14T14:26:56.742448621Z EXT TCP PORT ADVERTISE AS: 0 ()
exchange.eventstore | 2017-07-14T14:26:56.742451638Z EXT HTTP PORT ADVERTISE AS: 0 ()
exchange.eventstore | 2017-07-14T14:26:56.742454630Z INT IP ADVERTISE AS: ()
exchange.eventstore | 2017-07-14T14:26:56.742457717Z INT SECURE TCP PORT ADVERTISE AS: 0 ()
exchange.eventstore | 2017-07-14T14:26:56.742460775Z INT TCP PORT ADVERTISE AS: 0 ()
exchange.eventstore | 2017-07-14T14:26:56.742463654Z INT HTTP PORT ADVERTISE AS: 0 ()
exchange.eventstore | 2017-07-14T14:26:56.742466649Z INT TCP HEARTBEAT TIMEOUT: 700 ()
exchange.eventstore | 2017-07-14T14:26:56.742469637Z EXT TCP HEARTBEAT TIMEOUT: 1000 ()
exchange.eventstore | 2017-07-14T14:26:56.742472643Z INT TCP HEARTBEAT INTERVAL: 700 ()
exchange.eventstore | 2017-07-14T14:26:56.742475581Z EXT TCP HEARTBEAT INTERVAL: 2000 ()
exchange.eventstore | 2017-07-14T14:26:56.742478563Z GOSSIP ON SINGLE NODE: False ()
exchange.eventstore | 2017-07-14T14:26:56.742481420Z FORCE: False ()
exchange.eventstore | 2017-07-14T14:26:56.742484384Z CLUSTER SIZE: 1 ()
exchange.eventstore | 2017-07-14T14:26:56.742488327Z NODE PRIORITY: 0 ()
exchange.eventstore | 2017-07-14T14:26:56.742491620Z MIN FLUSH DELAY MS: 2 ()
exchange.eventstore | 2017-07-14T14:26:56.742494582Z COMMIT COUNT: -1 ()
exchange.eventstore | 2017-07-14T14:26:56.742497517Z PREPARE COUNT: -1 ()
exchange.eventstore | 2017-07-14T14:26:56.742500378Z ADMIN ON EXT: True ()
exchange.eventstore | 2017-07-14T14:26:56.742503245Z STATS ON EXT: True ()
exchange.eventstore | 2017-07-14T14:26:56.742506091Z GOSSIP ON EXT: True ()
exchange.eventstore | 2017-07-14T14:26:56.742531240Z DISABLE SCAVENGE MERGING: False ()
exchange.eventstore | 2017-07-14T14:26:56.742534922Z SCAVENGE HISTORY MAX AGE: 30 ()
exchange.eventstore | 2017-07-14T14:26:56.742538063Z DISCOVER VIA DNS: True ()
exchange.eventstore | 2017-07-14T14:26:56.742541143Z CLUSTER DNS: fake.dns ()
exchange.eventstore | 2017-07-14T14:26:56.742544204Z CLUSTER GOSSIP PORT: 30777 ()
exchange.eventstore | 2017-07-14T14:26:56.742547186Z GOSSIP SEED: ()
exchange.eventstore | 2017-07-14T14:26:56.742550347Z STATS PERIOD SEC: 30 ()
exchange.eventstore | 2017-07-14T14:26:56.742553357Z CACHED CHUNKS: -1 ()
exchange.eventstore | 2017-07-14T14:26:56.742556240Z READER THREADS COUNT: 4 ()
exchange.eventstore | 2017-07-14T14:26:56.742559366Z CHUNKS CACHE SIZE: 536871424 ()
exchange.eventstore | 2017-07-14T14:26:56.742562286Z MAX MEM TABLE SIZE: 1000000 ()
exchange.eventstore | 2017-07-14T14:26:56.742568383Z HASH COLLISION READ LIMIT: 100 ()
exchange.eventstore | 2017-07-14T14:26:56.742571695Z DB: /var/lib/eventstore ()
exchange.eventstore | 2017-07-14T14:26:56.742574805Z INDEX: ()
exchange.eventstore | 2017-07-14T14:26:56.742577974Z MEM DB: False ()
exchange.eventstore | 2017-07-14T14:26:56.742580905Z SKIP DB VERIFY: False ()
exchange.eventstore | 2017-07-14T14:26:56.742583893Z WRITE THROUGH: False ()
exchange.eventstore | 2017-07-14T14:26:56.742586847Z UNBUFFERED: False ()
exchange.eventstore | 2017-07-14T14:26:56.742589781Z PROJECTION THREADS: 3 ()
exchange.eventstore | 2017-07-14T14:26:56.742592742Z WORKER THREADS: 5 ()
exchange.eventstore | 2017-07-14T14:26:56.742595686Z ENABLE TRUSTED AUTH: False ()
exchange.eventstore | 2017-07-14T14:26:56.742598705Z CERTIFICATE STORE LOCATION: ()
exchange.eventstore | 2017-07-14T14:26:56.742601803Z CERTIFICATE STORE NAME: ()
exchange.eventstore | 2017-07-14T14:26:56.742604888Z CERTIFICATE SUBJECT NAME: ()
exchange.eventstore | 2017-07-14T14:26:56.742607980Z CERTIFICATE THUMBPRINT: ()
exchange.eventstore | 2017-07-14T14:26:56.742610951Z CERTIFICATE FILE: ()
exchange.eventstore | 2017-07-14T14:26:56.742613988Z CERTIFICATE PASSWORD: ()
exchange.eventstore | 2017-07-14T14:26:56.742616990Z USE INTERNAL SSL: False ()
exchange.eventstore | 2017-07-14T14:26:56.742619994Z DISABLE INSECURE TCP: False ()
exchange.eventstore | 2017-07-14T14:26:56.742622896Z SSL TARGET HOST: n/a ()
exchange.eventstore | 2017-07-14T14:26:56.742625903Z SSL VALIDATE SERVER: True ()
exchange.eventstore | 2017-07-14T14:26:56.742628761Z AUTHENTICATION TYPE: internal ()
exchange.eventstore | 2017-07-14T14:26:56.742631646Z AUTHENTICATION CONFIG: ()
exchange.eventstore | 2017-07-14T14:26:56.742634627Z PREPARE TIMEOUT MS: 2000 ()
exchange.eventstore | 2017-07-14T14:26:56.742637548Z COMMIT TIMEOUT MS: 2000 ()
exchange.eventstore | 2017-07-14T14:26:56.742640336Z UNSAFE DISABLE FLUSH TO DISK: False ()
exchange.eventstore | 2017-07-14T14:26:56.742643227Z BETTER ORDERING: False ()
exchange.eventstore | 2017-07-14T14:26:56.742646108Z UNSAFE IGNORE HARD DELETE: False ()
exchange.eventstore | 2017-07-14T14:26:56.742649597Z INDEX CACHE DEPTH: 16 ()
exchange.eventstore | 2017-07-14T14:26:56.742652723Z GOSSIP INTERVAL MS: 1000 ()
exchange.eventstore | 2017-07-14T14:26:56.742655662Z GOSSIP ALLOWED DIFFERENCE MS: 60000 ()
exchange.eventstore | 2017-07-14T14:26:56.742661267Z GOSSIP TIMEOUT MS: 500 ()
exchange.eventstore | 2017-07-14T14:26:56.742664524Z ENABLE HISTOGRAMS: False ()
exchange.eventstore | 2017-07-14T14:26:56.742667495Z LOG HTTP REQUESTS: False ()
exchange.eventstore | 2017-07-14T14:26:56.742670421Z ALWAYS KEEP SCAVENGED: False ()
exchange.eventstore | 2017-07-14T14:26:56.742673316Z
exchange.eventstore | 2017-07-14T14:26:56.742675828Z [00001,01,14:26:56.736] Quorum size set to 1
exchange.eventstore | 2017-07-14T14:26:56.792298847Z [00001,01,14:26:56.745] Cannot find plugins path: plugins
exchange.eventstore | 2017-07-14T14:26:56.842562341Z [00001,01,14:26:56.802] INSTANCE ID: 1415579d-8e9a-49fd-b19c-913bfda016fd
exchange.eventstore | 2017-07-14T14:26:56.842579833Z [00001,01,14:26:56.803] DATABASE: /var/lib/eventstore
exchange.eventstore | 2017-07-14T14:26:56.842583867Z [00001,01,14:26:56.803] WRITER CHECKPOINT: 0 (0x0)
exchange.eventstore | 2017-07-14T14:26:56.842587143Z [00001,01,14:26:56.803] CHASER CHECKPOINT: 0 (0x0)
exchange.eventstore | 2017-07-14T14:26:56.842590426Z [00001,01,14:26:56.803] EPOCH CHECKPOINT: -1 (0xFFFFFFFFFFFFFFFF)
exchange.eventstore | 2017-07-14T14:26:56.842593435Z [00001,01,14:26:56.803] TRUNCATE CHECKPOINT: -1 (0xFFFFFFFFFFFFFFFF)
exchange.eventstore | 2017-07-14T14:26:57.051783013Z [00001,01,14:26:57.004] MessageHierarchy initialization took 00:00:00.1396124.
exchange.eventstore | 2017-07-14T14:26:57.153910175Z [00001,01,14:26:57.124] Opened ongoing /var/lib/eventstore/chunk-000000.000000 as version 3
exchange.eventstore | 2017-07-14T14:26:57.154750364Z [00001,01,14:26:57.129] Unhandled exception while starting application:
exchange.eventstore | 2017-07-14T14:26:57.154761102Z Corrupt database detected.
exchange.eventstore | 2017-07-14T14:26:57.154765152Z [00001,01,14:26:57.142] Corrupt database detected.
exchange.eventstore | 2017-07-14T14:26:57.154768586Z Unexpected files: /var/lib/eventstore/chunk-000001.000000, /var/lib/eventstore/chunk-000002.000000, /var/lib/eventstore/chunk-000003.000000, /var/lib/eventstore/chunk-000004.000000.
exchange.eventstore | 2017-07-14T14:26:57.154772387Z Corrupt database detected.

``

Thanks for the logs, it does help and shows the issue.

As mentioned before, the error can occur due to the absense of the appropriate checkpoints. The following snippet below shows that the checkpoints are missing.

exchange.eventstore | 2017-07-14T14:26:56.842583867Z [00001,01,14:26:56.803] WRITER CHECKPOINT: 0 (0x0)
exchange.eventstore | 2017-07-14T14:26:56.842587143Z [00001,01,14:26:56.803] CHASER CHECKPOINT: 0 (0x0)
exchange.eventstore | 2017-07-14T14:26:56.842590426Z [00001,01,14:26:56.803] EPOCH CHECKPOINT: -1 (0xFFFFFFFFFFFFFFFF)

``

The checkpoints are the files alongside the db directory with the .chk extension.

  1. Do you see them present in the db directory?

  2. When you start the container, does it use a restored db?

Yes

exchange.eventstore | 2017-07-14T14:26:56.842583867Z [00001,01,14:26:56.803] WRITER CHECKPOINT: 0 (0x0)
exchange.eventstore | 2017-07-14T14:26:56.842587143Z [00001,01,14:26:56.803] CHASER CHECKPOINT: 0 (0x0)
exchange.eventstore | 2017-07-14T14:26:56.842590426Z [00001,01,14:26:56.803] EPOCH CHECKPOINT: -1 (0xFFFFFFFFFFFFFFFF)
exchange.eventstore | 2017-07-14T14:26:56.842593435Z [00001,01,14:26:56.803] TRUNCATE CHECKPOINT: -1 (0xFFFFFFFFFFFFFFFF)

Did you try to restore a backup etc? There are files missing.

The following files are present in db directory:

-rw-r–r-- 1 root root 8 Jul 14 16:18 chaser.chk
-rw-r–r-- 1 root root 268439552 Jul 14 16:18 chunk-000000.000000
-r–r--r-- 1 root root 268439552 Jul 2 21:18 chunk-000001.000000
-r–r--r-- 1 root root 268439552 Jul 8 16:15 chunk-000002.000000
-r–r--r-- 1 root root 268439552 Jul 14 11:12 chunk-000003.000000
-rw-r–r-- 1 root root 268439552 Jul 14 16:18 chunk-000004.000000
-rw-r–r-- 1 root root 8 Jul 14 16:18 epoch.chk
-rw-r–r-- 1 root root 8 Jul 14 16:18 truncate.chk
-rw-r–r-- 1 root root 8 Jul 14 16:18 writer.chk

``

The container has a mounted volume containing these files.

They should be correct, shouldn’t they?

When you restarted, the .chk files would have been recreated if they were not there to start with.

Thanks for your feedback. It might be that the container may be wrongly started or the volume has not been correctly attached while restarting the container. Unfortunately I cannot remember the exact steps we took since it was on a development machine and there was no backup either.**
Regarding the backup:**Is it possible to just copy away first the *.chk files and then the remaining files even while the event store is running? Is it sufficient to backup all the files in `/var/lib/eventstore or are there other necessary files? The documentation is a bit unspecific about which files needs to be backuped, it only says “``Copy the remaining files and directories”…

Thanks a lot!
`

The backup can be done while Event Store is still running, and yes, it is enough to simply backup all the files in the data directory (/var/lib/eventstore on ubuntu)

You just need to ensure that you always copy the *.chk files before copying the rest.

Thanks a lot!