Open arthurwolf opened 2 years ago
it's starting to look like this is a weird re-entry issue.
why is getNext() an async function but await isn't used when it's called?
a dirty fix to this was to change limit: 100 to limit: 100000000, it now works 100% of the time it also had a weird side effect: execution of simulations is MASSIVELY faster why was this limited to 100, was this built to be executed on a raspberry pi originally or something like that? it's a very small limit... or maybe there's an operational reason why you need to do it by small groups? the reverse/symmetry thing?
note: setting limit to very high values does not solve the issue, it just makes it much much more difficult to reproduce also, setting limit to 5 makes it much easier to reproduce
Replacing most of the getNext() function with simply:
let cur = tradesCollection.find(opts.query).sort(opts.sort);
let results = await cur.toArray();
results.forEach((trade, i) => {eventBus.emit('trade', trade)});
engine.exit(exitSim);
functions great (so far...) I'm loosing the "reverse" feature, which I don't use/understand. If I understood what it is maybe I could re-implement it, will look into it.
Down to two lines, works perfectly. Doesn't have the "symmetry" feature, but I don't understand that well enough to implement it. Any explanations welcome:
await tradesCollection.find(opts.query).batchSize(10).sort(opts.sort).forEach((trade, i) => {eventBus.emit('trade', trade)});
engine.exit(exitSim);
Describe the problem
Zenbot just holds on a regular basis during simulations.
I added tons of console.logs to trace the issue, and it seems like I get to onCollectionCursorEnd in sim.js, with numTrades != 0 it goes into the "else", so the engine.exit(exitSim) isn't hit, and from there it just does nothing anymore.
What is this "else" for and what is supposed to happen once it's hit?
I do not think this has to do with my custom strategy, but I could very well be wrong. Would still appreciate any idea in debugging this so I can fix whatever is happening here.
here's the order things happen during a crash: