askmike / gekko

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

SQLITE_BUSY: database is locked #1189

Closed bokub closed 6 years ago

bokub commented 6 years ago

Started from a clean repo (first time with gekko) Ran npm install Ran node gekko --ui Added a new 'paper trader' gekko using the interface, with default options

Immediate alert() popup saying 'GEKKO ERROR: Child process has died.'

Stacktrace here ``` TAlib is disabled Serving Gekko UI on http://localhost:3000/ <-- GET /api/imports --> GET /api/imports 200 5ms 2b <-- GET /api/gekkos --> GET /api/gekkos 200 1ms 2b <-- GET /api/apiKeys --> GET /api/apiKeys 200 1ms 2b <-- GET /api/exchanges --> GET /api/exchanges 200 1,008ms 58.82kb <-- GET /api/gekkos --> GET /api/gekkos 200 1ms 2b <-- GET /api/imports --> GET /api/imports 200 1ms 2b <-- GET /api/gekkos --> GET /api/gekkos 200 0ms 2b <-- GET /api/apiKeys --> GET /api/apiKeys 200 2ms 2b <-- GET /api/exchanges <-- GET /api/gekkos --> GET /api/gekkos 200 0ms 2b --> GET /api/exchanges 200 8ms 58.82kb <-- GET /api/imports --> GET /api/imports 200 1ms 2b <-- GET /api/gekkos --> GET /api/gekkos 200 1ms 2b <-- GET /api/apiKeys --> GET /api/apiKeys 200 1ms 2b <-- GET /api/exchanges <-- GET /api/gekkos --> GET /api/gekkos 200 1ms 2b --> GET /api/exchanges 200 7ms 58.82kb <-- GET /api/configPart/candleWriter <-- GET /api/configPart/performanceAnalyzer --> GET /api/configPart/candleWriter 200 8ms 47b --> GET /api/configPart/performanceAnalyzer 200 6ms 144b <-- GET /api/strategies --> GET /api/strategies 200 3ms 1.49kb <-- GET /api/configPart/paperTrader --> GET /api/configPart/paperTrader 200 1ms 132b <-- GET /api/configPart/candleWriter <-- GET /api/configPart/performanceAnalyzer --> GET /api/configPart/candleWriter 200 7ms 47b --> GET /api/configPart/performanceAnalyzer 200 8ms 144b <-- GET /api/strategies --> GET /api/strategies 200 3ms 1.49kb <-- GET /api/configPart/paperTrader --> GET /api/configPart/paperTrader 200 1ms 132b <-- POST /api/startGekko Gekko 353267897781442 started --> POST /api/startGekko 200 22ms 146b <-- POST /api/startGekko Gekko 034881364069969 started --> POST /api/startGekko 200 12ms 446b <-- POST /api/getCandles --> POST /api/getCandles 200 329ms 2b events.js:182 throw er; // Unhandled 'error' event ^ Error: SQLITE_BUSY: database is locked RECEIVED ERROR IN GEKKO 034881364069969 Child process has died. ```

P.S I saw the other related issues. In other threads, the problems occurs after a few hours, mine occurs immediately. I do not have multiple instances of gekko running.

generalectric commented 6 years ago

What operating system are you running?

bokub commented 6 years ago

Sorry I forgot that detail Linux Mint 18

generalectric commented 6 years ago

Have you tried changing the journal mode from WAL to DEL in plugins/sqlite/handle.js? Possibly totally unrelated but I have had issues in the past with sqlite and database locking and for me my problem was solved by changing the journal mode.

bokub commented 6 years ago

Thanks for your quick answer, but that did not fix the problem. The behavior and stacktrace are exactly the same

bokub commented 6 years ago

I see that there is a mongodb pulgin. Can I use it instead of sqlite ? How ?

I cannot find anything related in the documentation

grunt-logic commented 6 years ago

Running sudo node gekko --ui on startup fixed this for me. User permissions issue maybe?

bokub commented 6 years ago

Nope, still an error.

However, I have noticed something really interesting: The problem occurs when I add a gekko on a Bitstamp market, but not on a Poloniex or a Bittrex market.

xerix32 commented 6 years ago

This works for me, try to add

+db.configure('busyTimeout', 1500); in plugins/sqlite/handle.js

This raises busyTimeout.

My Pull Reuest

darkcloud8 commented 6 years ago

i had this same issue for paper trader on version 0.5.8 for BTC Markets. i just recompiled the version 0.5.9 and the same issue is still occurring. i have tried Poloniex and its not happening on that market. it has not been fixed for BTC Markets

Error messsage in the console: Gekko 1468339149843594 started
--> POST /api/startGekko 200 216ms 151b
<-- POST /api/startGekko
Gekko 2426912742571705 started
--> POST /api/startGekko 200 199ms 450b
<-- POST /api/getCandles
events.js:160
throw er; // Unhandled 'error' event
^

Error: SQLITE_BUSY: database is locked
at Error (native)
RECEIVED ERROR IN GEKKO 2426912742571705
Child process has died.

askmike commented 6 years ago

@darkcloud8 can you be more specific in what you are doing: When this happens how many gekkos are running (UI + commandline)? How many of those use BTC-markets?

darkcloud8 commented 6 years ago

Only 1 gekko running in UI mode. I start Paper Trader for BTC-markets and set it to AUD to BTC. Left everything else on default and click start. Within 5secs of starting it i get the error the Child process has died on the UI and i check the console it gives me that error message in the previous comment.

askmike commented 6 years ago

And the exact same behaviour doesn't happen on any other exchange? That's really weird, the error you are seeing has nothing to do with BTC-markets.

On Tue, Oct 24, 2017 at 4:51 PM, darkcloud8 notifications@github.com wrote:

Only 1 gekko running in UI mode. I start Paper Trader for BTC-markets and set it to AUD to BTC. Left everything else on default and click start. Within 5secs of starting it those the Child process has died on the UI and i check the console it gives me that error message above.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/askmike/gekko/issues/1189#issuecomment-338937026, or mute the thread https://github.com/notifications/unsubscribe-auth/AA7MDz96tzoBR3G_TGIY67R4czYwbYLLks5svbMKgaJpZM4PxXsm .

-- PGP key at keybase.io/mikevanrossum https://keybase.io/mikevanrossum/key.asc

darkcloud8 commented 6 years ago

I have only tested Poloniex but i will test the rest now and get back to you.

xerix32 commented 6 years ago

Can be related to the number of transaction ? BTC has generally more volume/transactions to write on DB.

I think is related on hardware too, I see the problem only on raspberry (on my notebook works good), but with 1500 timeout I've no problems.

What hardware have you?

darkcloud8 commented 6 years ago

I'm running it on my QNAP TS-453A in the Container Station.

My setup on the QNAP is running 3 docker containers 1: CommandLine Only running a Watcher on BTC-Markets AUD-BTC 2: CommandLine Only running a Watcher on BTC-Markets AUD-ETH 3: UI trying to run the BTC-Markets Paper Trader for AUD-BTC

All 3 containers have separate history folders

darkcloud8 commented 6 years ago

@askmike i have tested all the markets, the ones below throw me errors on Paper Trader with default options. It seems like the error i'm getting on BTC-Markets is happening on kraken too. All the others looks like different errors. Hope that is useful information.

bx.in.th Gekko 633825640172174 started
--> POST /api/startGekko 200 291ms 147b

/usr/src/app/core/budfox/tradeBatcher.js:40
throw 'tid is not a string';
^
tid is not a string
RECEIVED ERROR IN GEKKO 633825640172174
Child process has died.

cexio Gekko 633825640172174 started
--> POST /api/startGekko 200 291ms 147b

/usr/src/app/core/budfox/tradeBatcher.js:40
throw 'tid is not a string';
^
tid is not a string
RECEIVED ERROR IN GEKKO 633825640172174
Child process has died.

kraken Gekko 491472340492585 started
--> POST /api/startGekko 200 106ms 145b
<-- POST /api/startGekko
Gekko 21218850992437 started
--> POST /api/startGekko 200 202ms 443b
<-- POST /api/getCandles
events.js:160
throw er; // Unhandled 'error' event
^

Error: SQLITE_BUSY: database is locked
at Error (native)
RECEIVED ERROR IN GEKKO 21218850992437
Child process has died.

lakebtc Doesn't show an error but it doesn't even start (seems like i can't connect to the server)

askmike commented 6 years ago

Ah you picked some very old exchanges haha. Anyway:

Error: SQLITE_BUSY: database is locked

This is most likely related to your NAS. Especially if you are not running any other Gekko at the same time. Would you be able to test Gekko on anything else (laptop, computer, server) to see if Kraken, Poloniex, Bitstamp or GDAX works?

darkcloud8 commented 6 years ago

i tried it on my laptop, Kraken, Poloniex, Bitstamp and GDAX all works fine but with BTC-Markets i still get a Child process has died error on the UI. The Watcher still looks like its running, i can confirm about the Paper Trader part has stopped updating.

darkcloud8 commented 6 years ago

i tried Kraken on a few different Currency to Asset setup and everything else on default on Paper Trader. I have notice that Kraken and BTC-Market both imports massive amount of data depend on what time of the day it is. Anything over 4-5hours of data the Paper Trader will crash and throw the Child process has died error. I'm testing this on my laptop and not my NAS. If you go try Kraken with JPY to ETH setting, it is throwing the error 100% of the time because the data is at 1 Day 3 Hours + right now.