Skip to content
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

fix: Don't crash indexer on an "UNKNOWN: unknown error, lstat" error #898

Merged
merged 3 commits into from
Dec 16, 2022

Conversation

symwell
Copy link
Contributor

@symwell symwell commented Dec 12, 2022

Attempts to fix #897. Created from branch sw/disable_watching_on_ENOSPC_error

This error is an exception thrown by chokidar while file watching.

I wasn't able to reproduce this error. I created symlinks and deleted them programmatically when the queue processes the file but this produced an ENOENT error.

File /home/test/tmp/too_many_open_files/minitest/Static_pages_controller_should_get_help.appmap.json does not exist or is not a file.
Deleted File successfully.
[Error: ENOENT: no such file or directory, lstat '/home/test/tmp/too_many_open_files/minitest/Static_pages_controller_should_get_home.appmap.json'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: '/home/test/tmp/too_many_open_files/minitest/Static_pages_controller_should_get_home.appmap.json'
}

There's a claim this UNKNOWN: unknown error, lstat error is the result of file corruption down at the NTFS level.
nodejs/node#43439

@symwell symwell force-pushed the sw/disable_watching_on_ENOSPC_error branch from 9e6032a to 87b0a34 Compare December 12, 2022 19:45
@symwell symwell changed the title fix: Don't crash on an 'UNKNOWN: unknown error, lstat' error fix: Don't crash on an "UNKNOWN: unknown error, lstat" error Dec 13, 2022
@symwell symwell force-pushed the sw/dont_crash_on_unknown_error_lstat__version2 branch 2 times, most recently from bcde674 to d5c877c Compare December 13, 2022 14:14
Base automatically changed from sw/disable_watching_on_ENOSPC_error to main December 13, 2022 14:32
@symwell symwell force-pushed the sw/dont_crash_on_unknown_error_lstat__version2 branch from d5c877c to dd80f92 Compare December 13, 2022 14:33
@dustinbyrne dustinbyrne requested a review from ahtrotta December 13, 2022 15:29
@ahtrotta
Copy link
Contributor

I don't think we should catch this error if we don't understand why it's happening. It's possible it could be a UTF-8 problem. Or it could be the corrupt file like you linked to above. Or it might have to do with a faulty npm cache. Bottom line is, I think we shouldn't mess with it until we understand it. It does seem like it's a Windows problem, so maybe someone with a Windows machine should tackle this.

@dustinbyrne
Copy link
Contributor

I'd be fine with not propagating unknown errors into a panic as long as we emit the exception as a telemetry event:

// let it crash if it's some other error, to learn what the error is
throw error;

Is there a chance this method would be invoked repeatedly on an unreadable file? If so, that's a bigger issue.

@symwell symwell force-pushed the sw/dont_crash_on_unknown_error_lstat__version2 branch from add91e1 to 2f3fde9 Compare December 13, 2022 21:38
@symwell
Copy link
Contributor Author

symwell commented Dec 13, 2022

Added index:watcher_error:unknown telemetry event. Also added in telemetry spreadsheet.

Is there a chance this method would be invoked repeatedly on an unreadable file? If so, that's a bigger issue.

If you mean getting stuck on an unreadable file and not processing other files, I think yes. Running ls on mounted images that contain unreadable files on Linux gets stuck, pressing ctrl-c doesn't stop.

This error was encountered 2 times in telemetry. Maybe it's not worth adding logic that will bypass such unreadable files right now.

@symwell symwell force-pushed the sw/dont_crash_on_unknown_error_lstat__version2 branch from 2f3fde9 to 1a77606 Compare December 13, 2022 21:44
@symwell
Copy link
Contributor Author

symwell commented Dec 15, 2022

I don't think we should catch this error if we don't understand why it's happening.

Maybe we can do both. Catch this error, to reach the goal of not letting the indexer crash. And send telemetry with the error message, to help understand why it's happening.

@ahtrotta
Copy link
Contributor

If you mean getting stuck on an unreadable file and not processing other files, I think yes. Running ls on mounted images that contain unreadable files on Linux gets stuck, pressing ctrl-c doesn't stop.

I think this is a problem. I don't think we should release it in its current form if this is the behavior. Maybe you could console.warn and send a telemetry event like you do now, and then add throw error after so that it doesn't get stuck on an unreadable file. That way we could get more information on the error and not have the program get stuck.

Alternatively, maybe we could catch the error, then add the file to a list of files to skip while watching/polling.

@symwell symwell force-pushed the sw/dont_crash_on_unknown_error_lstat__version2 branch from 1a77606 to c9eaf83 Compare December 15, 2022 19:46
@symwell symwell changed the title fix: Don't crash on an "UNKNOWN: unknown error, lstat" error fix: Don't crash indexer on an "UNKNOWN: unknown error, lstat" error Dec 15, 2022
@symwell symwell force-pushed the sw/dont_crash_on_unknown_error_lstat__version2 branch from d020e6e to 24bf529 Compare December 16, 2022 14:14
@symwell symwell force-pushed the sw/dont_crash_on_unknown_error_lstat__version2 branch from 24bf529 to 96104ae Compare December 16, 2022 14:31
@symwell
Copy link
Contributor Author

symwell commented Dec 16, 2022

Added the ability to save unreadable files in a Set and ignore them.

Added logic in testcases. Also tested by copying and executing this logic for ENOSPC which is easily reproducible. It showed files were added to unreadableFiles correctly.
unreadableFiles

If we throw error then the indexer will exit.

@symwell symwell merged commit 501a206 into main Dec 16, 2022
@symwell symwell deleted the sw/dont_crash_on_unknown_error_lstat__version2 branch December 16, 2022 21:27
@appland-release
Copy link
Contributor

🎉 This PR is included in version @appland/appmap-v3.55.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Indexer exits with Error: UNKNOWN: unknown error, lstat
4 participants