introduce query rows limit to avoid OOM #151
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
so I realized that my machine will OOM if I run (by mistake) a very large query with dadbod. Thanks to the linux OOM killer, my machine is only unresponsive for some number of seconds, but then (in the best case) neovim is killed, which is not ideal.
People should not make mistakes, but...
So this change introduces a configurable max number of rows to fetch before aborting a query to avoid such situations.
There is a least one little issue with this patch: if the limit is in fact reached, and rows come in fast, the warning "Query aborted..." can be written multiple times to the output before the writes do in fact stop.UPDATE: made a followup force push that fixes the writing "query aborted" multiple times and also the case where the file would be truncated in the middle of a line.