-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DocumentMigrator: add logging for errors outside of migration functions #76477
DocumentMigrator: add logging for errors outside of migration functions #76477
Conversation
expect(mockLogger.warn).toHaveBeenCalledTimes(1); | ||
expect(mockLogger.error).not.toHaveBeenCalled(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error from within the wrapped transform functions are currently logged as warnings
kibana/src/core/server/saved_objects/migrations/core/document_migrator.ts
Lines 339 to 341 in 079ef06
log.warn( | |
`Failed to transform document ${doc}. Transform: ${failedTransform}\nDoc: ${failedDoc}` | |
); |
As the error is actually causing the migration to fail and the server to not start, I wonder if we shouldn't upgrade that to the error
level, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrade to error makes sense 👍
if (!e.alreadyLogged) { | ||
log.error(`Error applying migrations to doc ${doc.type}:${doc.id}: ${e}`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The errors were already logged when thrown from within the migration function, via the wrapWithTry
wrapper. Only non-logged errors are the one from the actual DocumentMigrator code.
As the migration function errors got some specific infos, I did not remove them when adding this try/catch block. Instead, I use this alreadyLogged
flag trick to avoid logging the error twice, while preserving the thrown error.
Pinging @elastic/kibana-platform (Team:Platform) |
…-doc-migrator-error
…-doc-migrator-error
💚 Build SucceededBuild metrics
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good. Only remaining question I have is where were these exceptions being swallowed before? Is it possible that any other exceptions are being swallowed in the same place?
Don't even know why I did not look a little deeper, as every uncatched exceptions are supposed to be catched by root kibana/src/core/server/root/index.ts Lines 60 to 68 in 200957b
After a little more investigation, I found the actual culprit:
This recent addition to avoid blocking the event loop during migration does not handle error during the failure call, resulting in an unhandled promise rejection. |
Closing in favor of #77018 |
Summary
Fix #75055
Add logging of errors occurring from outside of the wrapped migration function to
DocumentMigrator.migrate
Checklist