Rebuild Database: failed to vacuum: constraint failed

Hello to everyone,
My user-manager - coreRouter all this morning had been suffering of micro-Powerdowns ( I think UPS is almost died).

A few hours later I detected that I couldn’t login, get routed through it or event ping it from anywhere. I hard rebooted it and I had these entries on log (in bold the interesting ones):

21:05:59 system,error,critical router was rebooted without proper shutdown 
[b]21:06:31 manager,error,info,debug failed to find session by acctSessionId: datab
ase disk image is malformed 
21:06:31 manager,error,info,debug failed to add session: columns acctSessionId, 
ipRouter, nasPortType are not unique [/b]
...
21:08:17 manager,error,info,debug failed to find session count: database disk im
age is malformed 
21:08:17 manager,error,info,debug table session is corrupted: 0x7fed05e0 
21:10:54 manager,error,info,debug failed to find session by acctSessionId: datab
ase disk image is malformed 
21:10:54 manager,error,info,debug failed to add session: columns acctSessionId, 
ipRouter, nasPortType are not unique 
...
21:11:27 system,info,account user admin logged in from 192.168.253.4 via telnet 
21:11:28 manager,error,info,debug failed to find session count: database disk im
age is malformed 
21:11:28 manager,error,info,debug table session is corrupted: 0x7fed05e0 
...
[b]21:14:35 manager,error,info,debug failed to vacuum: constraint failed 
[/b]21:15:23 system,info device changed by admin 
21:15:23 system,info,account user admin logged out from 192.168.253.4 via winbox
 
21:15:23 system,info,account user admin logged out from 192.168.253.4 via telnet
 
21:16:15 manager,error,info,debug failed to find session count: database disk im
age is malformed 
[b]21:16:15 manager,error,info,debug table session is corrupted: 0x7fed05e0 
21:17:03 manager,error,info,debug failed to find sessions: database disk image i
s malformed 
21:17:08 manager,error,info,debug failed to find sessions: database disk image i
s malformed 
21:17:11 manager,error,info,debug failed to find sessions: database disk image i
s malformed 
21:17:13 manager,error,info,debug failed to find sessions: database disk image i
s malformed 
21:17:15 manager,error,info,debug failed to find sessions: database disk image i
s malformed [/b]
21:18:06 system,info,account user admin logged in from 192.168.253.4 via winbox 
21:18:21 system,info,account user admin logged out from 192.168.253.4 via winbox

Entries with HEX code in them appeared when I logged in UserManager Web.

At
21:14:35 manager,error,info,debug failed to vacuum: constraint failed
I tried the following:

/tool user-manager database> rebuild  
Can take a while. Console may not respond while in progress. Rebuild user-manage
r database? [y/N]: 
y
Rebuilding user-manager database
failed to vacuum: constraint failed

When logged in UserManager, I observed “Active Sessions” counter was not counting sessions, but when showing sessions, it counts the “aproximately correct number of current sessions”, it generates the page , but no session is shown and Log showed:

21:35:34 manager,error,info,debug failed to find session count: database disk im
age is malformed 
21:35:34 manager,error,info,debug table session is corrupted: 0x7f83ea60 
21:35:37 manager,error,info,debug failed to find sessions: database disk image i
s malformed 
21:36:19 manager,error,info,debug failed to find session count: database disk im
age is malformed 
21:36:19 manager,error,info,debug table session is corrupted: 0x7f83ea60

Now my hotspots are validating users but sessions are written somewhere near to noplace.
I understand from errors thrown that Sessions Database (or tables, I don’t know how they are stored) is corrupted and cannot be rebuild because there’s a restriction that cannot be verified.

If only there was a way to swap out the corrupted part of the database and continue from then I could be not happy but at least relaxed.

I have a supout done after the hard-reboot and a while more, and another one done after a proper rebooting and a few errors, that are on their way to support mailbox.

Any idea about why this happened, and very importnat, how to solve it?

does running a /tool check-disk fix it ?

I didn’t tried it.
I’ll try in an hour or so, to let all clients going to sleep and leave their p2p apps running alone.

Hello danielillu and all does the command “/system check-disk” fix the problem?