tpope / vim-dadbod

dadbod.vim: Modern database interface for Vim
https://www.vim.org/scripts/script.php?script_id=5665
3.74k stars 131 forks source link

introduce query rows limit to avoid OOM #151

Open emmanueltouzery opened 11 months ago

emmanueltouzery commented 11 months ago

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.