askmike / gekko

A bitcoin trading bot written in node - https://gekko.wizb.it/
MIT License
10.07k stars 3.94k forks source link

SQlite is locked #1877

Closed RobertPelzer closed 5 years ago

RobertPelzer commented 6 years ago

Note: for support questions, please join our Discord server

Error: SQLITE_BUSY: database is locked RECEIVED ERROR IN GEKKO 3713240289149136 Child process has died.

I uninstalled and re-installed using git it once and just after a fresh start it worked. But the second try didn´t anymore Thanks

askmike commented 6 years ago

We had an active contributor that wrote all the documentation for running Gekko on windows using bash shell. However I haven't seen him around for a while now (maybe he'll respond anyway: ping @thegamecat).

Unfortunately it's hard for me to support windows as I don't have a windows machine. Maybe @cmroche can weigh in?

kifirkin commented 6 years ago

@RobertPelzer try to increase busyTimeout inside plugins/sqlite/handle.js#L55

cmroche commented 6 years ago

@RobertPelzer The lock error will generally happen when you have multiple processing access the database at the same time, every market watcher, trader, importer and even the database scanner (which shows imported data) all run in their own process and can cause this type of contention. You have to be mindful not to try and write with multiple process at the same time, ie: 1 import process per exchange.

That being said, I've have on rare occasion seen it when I'm not expecting it, particularly on Windows, but I have not been able to consistently cause it or diagnose the problem. Can you tell me a bit about what you were doing at the time?

How many gekkos? Back testing, importing, which exchange, which version of Windows, and are you using NTFS or FAT32 file system or a network file system for your database?

You can do as @alexmironof suggested too an increase the timeout, if that is all it takes to resolve your issue please report back so we can bump it in the code for everyone.

caafff commented 6 years ago

@cmroche I had the same issue as @RobertPelzer. However, I followed @alexmironof 's advice and it fixed. busyTimeout was 1500, so I changed to 15000. It works fine. I tried it on several platforms such as bitfinex, kraken and binance. It works properly and doesn't make any problems.

I hope this feedback is helpful to other people as well :)

cmroche commented 6 years ago

@caafff OK thank you for the feedback. Can you tell me a little bit about the specs of your PC? Are you using a magnetic disk drive (or SSD)?

15000 is probably a bit too much, it means that any process trying to access the database will wait 15 seconds for a write lock before proceeding, perhaps try starting at something a bit more mediocre such as 5000.

caafff commented 6 years ago

@cmroche Yea, sure. CPU: I3-4160, GPU: Nvidia GTX 750 TI, and HDD. Besides, I understand what you mean, but I was lazy. So I just put one more zero behind 1500 XD I tried 3000, 5000, 7000, 10000, 12000, 15000 so far 1) 3000 makes a problem 2) 5000 is half and half 3) over 7000, there is no issue

cmroche commented 6 years ago

Great, thank you for the details... I suspect performance is the obvious issue. The DB operations are async, so I don't think there is a large risk in increasing these values, I'll run a test on my side to confirm and update the defaults if it doesn't give me problems.

RobertPelzer commented 6 years ago

Hey @caafff , thanks for the advice. Increasing buysTimout did it for me also. Tried 5000 first, which didn´t work, but 15000 works fine. @cmroche I have a HDD NTFS with Winows 10 but no multiple gekkos running. This error occurs after startup. Backtesting is working just fine as well as importing data. But even without any running imports, backtests or other Live sessions, when I started a live gekko the problem occured.

kifirkin commented 6 years ago

@cmroche I could confirm that this kind of error occurs only when live gekko starts. And for me busyTimeout: 5000 works well even on my 5 years old hardware

zappra commented 6 years ago

I'm still seeing a lot of this error, doing backtesting via the UI.

It's intermittent and I haven't been able to nail down a solid repro. It seems to be related to db files with tables for more than one currency pair, and increasing the timeout doesn't help. For example, I'll get a bunch of errors when scanning for local data prior to a backtest.

I'm running on Mac OS X on SSD.

Anyone got any pointers for places I can hack about in the codebase?

Best z

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you feel this is very a important issue please reach out the maintainer of this project directly via e-mail: gekko at mvr dot me.