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

Treat javascript internal errors as fatal #4505

Merged
merged 1 commit into from
Mar 29, 2023

Conversation

nickva
Copy link
Contributor

@nickva nickva commented Mar 29, 2023

Spidermonkey sometimes throws an InternalError when exceeding memory limits, when normally we'd expect it to crash or exit with a non-0 exit code. Because we trap exceptions, and continue emitting rows, it is possible for users views to randomly miss indexed rows based on whether GC had run or not, other internal runtime state which may have been consuming more or less memory until that time.

To prevent the view continuing processing documents, and randomly dropping emitted rows, depending on memory pressure in the JS runtime at the time, choose to treat Internal errors as fatal.

After an InternalError is raised we expect the process to exit just like it would during OOM.

Add a test to assert this happens.

Fix #4504

Copy link
Member

@davisp davisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly good but I think we might want to rearrange that error checking conditonal.

share/server/loop.js Outdated Show resolved Hide resolved
Spidermonkey sometimes throws an `InternalError` when exceeding memory limits,
when normally we'd expect it to crash or exit with a non-0 exit code. Because
we trap exceptions, and continue emitting rows, it is possible for users views
to randomly miss indexed rows based on whether GC had run or not, other
internal runtime state which may have been consuming more or less memory until
that time.

To prevent the view continuing processing documents, and randomly dropping
emitted rows, depending on memory pressure in the JS runtime at the time,
choose to treat Internal errors as fatal.

After an InternalError is raised we expect the process to exit just like it
would during OOM.

Add a test to assert this happens.

Fix #4504
@nickva nickva force-pushed the hard-crash-on-internal-error-in-couch-js branch from 4a66ebe to 081c768 Compare March 29, 2023 20:24
Copy link
Member

@davisp davisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@nickva nickva merged commit cd77b07 into main Mar 29, 2023
@nickva nickva deleted the hard-crash-on-internal-error-in-couch-js branch March 29, 2023 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Out-of-memory InternalError exceptions in couchjs
2 participants