zadam / trilium

Build your personal knowledge base with Trilium Notes
GNU Affero General Public License v3.0
27.2k stars 1.9k forks source link

Filling entity changes failed #1898

Closed user9931 closed 3 years ago

user9931 commented 3 years ago

For bug reports, PLEASE mention version of Trilium you're using and also include log files from following location:

Some time ago i'm stuck with 0.45.8 so now i'm trying to update to actual release. I'm trying to check database consistency, then trying "Fill entity changes records", then consistency again... and it happens. Its really errors or it can be ignored?

trilium-2021-04-27.log

11:34:06.285 DB size: 19165 KB
11:34:07.109 Note cache load took 15ms
11:34:07.301 App HTTP server starting up at port 37840
11:34:07.301 {
  "appVersion": "0.47.2",
  "dbVersion": 183,
  "syncVersion": 20,
  "buildDate": "2021-04-26T22:32:54+02:00",
  "buildRevision": "6f1b0b92fe8dcea736c15217c69512c7fee769cb",
  "dataDirectory": "C:\\Users\\Hotery\\Downloads\\trilium-windows-x64-0.47.2\\trilium-windows-x64\\\\trilium-data",
  "clipperProtocolVersion": "1.0"
}
11:34:07.302 CPU model: AMD Ryzen 7 3700X 8-Core Processor             , logical cores: 16 freq: 3593 Mhz
11:34:07.322 Registered global shortcut Ctrl+Alt+P for action createNoteIntoInbox
11:34:07.323 Listening on port 37840
11:34:07.419 Generated CSRF token TJiIbsNa-b-yz04KXU9JGnX8yhnLzFUzp860 with secret _csrf=jXiAFytwBhgMXJY_32k5QNhK; Path=/
11:34:07.431 Slow 200 GET / took 13ms
11:34:07.706 200 GET /api/options took 1ms
11:34:07.709 200 GET /api/tree took 2ms
11:34:07.712 200 GET /api/keyboard-actions took 1ms
11:34:07.714 200 GET /api/keyboard-shortcuts-for-notes took 0ms
11:34:07.715 200 GET /api/script/widgets took 1ms
11:34:08.175 200 GET /api/notes/r7BeRv8Z8g3n took 2ms
11:34:08.606 304 GET /api/images/PZkiRO6GOOWZ/image.png took 0ms
11:34:09.239 Slow 200 GET /api/similar-notes/r7BeRv8Z8g3n took 75ms
11:34:09.248 200 GET /api/notes/r7BeRv8Z8g3n/revisions took 1ms
11:34:09.251 200 POST /api/tree/load took 2ms
11:34:09.748 200 GET /api/script/startup took 1ms
11:34:11.810 200 GET /api/backend-log took 3ms
11:34:13.153 Slow 204 POST /api/recent-notes took 11ms
11:34:16.060 200 GET /api/options took 1ms
11:34:16.123 200 GET /api/keyboard-actions took 2ms
11:34:16.124 200 GET /api/options/user-themes took 1ms
11:34:16.192 No connection to sync server.
11:34:18.077 204 POST /api/database/find-and-fix-consistency-issues took 0ms
11:34:18.078 Table counts: notes: 1203, note_revisions: 1160, branches: 1389, attributes: 556, api_tokens: 2
11:34:18.110 Slow query took 27ms: SELECT noteId FROM notes JOIN note_contents USING (noteId) WHERE isDeleted = 0 AND isProtected = 0 AND content IS NULL
11:34:18.125 All consistency checks passed (took 48ms)
11:34:27.115 Table counts: notes: 1203, note_revisions: 1160, branches: 1389, attributes: 556, api_tokens: 2
11:34:27.134 All consistency checks passed (took 20ms)
11:34:30.703 200 GET /api/backend-log took 2ms
11:34:38.454 200 GET /api/options took 1ms
11:34:38.493 200 GET /api/keyboard-actions took 1ms
11:34:38.494 200 GET /api/options/user-themes took 0ms
11:34:40.307 ERROR: Filling entity changes failed for notes noteId with error "NOT NULL constraint failed: entity_changes.hash", continuing
11:34:40.308 ERROR: Filling entity changes failed for note_contents noteId with error "NOT NULL constraint failed: entity_changes.hash", continuing
11:34:40.309 ERROR: Filling entity changes failed for branches branchId with error "NOT NULL constraint failed: entity_changes.hash", continuing
11:34:40.310 ERROR: Filling entity changes failed for note_revisions noteRevisionId with error "NOT NULL constraint failed: entity_changes.hash", continuing
11:34:40.311 ERROR: Filling entity changes failed for note_revision_contents noteRevisionId with error "NOT NULL constraint failed: entity_changes.hash", continuing
11:34:40.312 ERROR: Filling entity changes failed for recent_notes noteId with error "NOT NULL constraint failed: entity_changes.hash", continuing
11:34:40.312 ERROR: Filling entity changes failed for attributes attributeId with error "NOT NULL constraint failed: entity_changes.hash", continuing
11:34:40.312 ERROR: Filling entity changes failed for api_tokens apiTokenId with error "NOT NULL constraint failed: entity_changes.hash", continuing
11:34:40.313 ERROR: Filling entity changes failed for options name with error "NOT NULL constraint failed: entity_changes.hash", continuing
11:34:40.313 Sync rows have been filled.
11:34:40.315 Slow 204 POST /api/sync/fill-entity-changes took 15ms
11:34:44.263 200 GET /api/backend-log took 7ms
11:35:03.095 304 GET /api/clipper/handshake took 1ms
11:35:11.189 No connection to sync server.
11:35:17.687 200 GET /api/options took 0ms
11:35:17.719 200 GET /api/keyboard-actions took 2ms
11:35:17.720 200 GET /api/options/user-themes took 0ms
11:35:19.385 204 POST /api/database/find-and-fix-consistency-issues took 0ms
11:35:19.385 Table counts: notes: 1203, note_revisions: 1160, branches: 1389, attributes: 556, api_tokens: 2
11:35:19.394 Consistency issue fixed: Created missing entity change for entityName=notes, entityId=01JVHtayu0ud
11:35:19.395 Consistency issue fixed: Created missing entity change for entityName=notes, entityId=03Vl3moaWC5h
11:35:19.395 Consistency issue fixed: Created missing entity change for entityName=notes, entityId=074TKe5oBxJe
11:35:19.395 Consistency issue fixed: Created missing entity change for entityName=notes, entityId=083s4iHf66dh
<CUT, about hundreds of lines,>

And second thing - something went wrong with gui (desktop app and web ui on linux server) image I'm checked with empty database and gui looks ok, so maybe something with database?

And, after that "Consistency issue fixed", "Fill entity changes records" then "Find and fix consistency issues" produces the same output as in log above.

Sorry about too old version. All this errors happens on both old 0.45.8 and (when it succesfully migrating) 0.47.2, only difference is broken ui

zadam commented 3 years ago

Hi, do I assume correctly that if you start the app again, all of these "Consistency issue fixed:" do not happen again? On the first look it seems to me that the problem was automatically fixed ... If that's the case then you should be fine. I will investigate where does the original error come from either way though ...

And second thing - something went wrong with gui (desktop app and web ui on linux server)

What's the issue? Screenshot seems to me fine ...

zadam commented 3 years ago

So I managed to reproduce it. I think you clicked on this button:

image

But then consistency checker automatically fixes all the missing "entity changes" so the whole thing is quite harmless.

But the "Fill entity changes record" is obviously broken and needs to be fixed. So please don't click on it in the mean time (you shouldn't really have a reason to do that anyway)