Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite in-memory database disappears and ledger crashes #354

Open
dappelt opened this issue Nov 9, 2016 · 3 comments
Open

sqlite in-memory database disappears and ledger crashes #354

dappelt opened this issue Nov 9, 2016 · 3 comments

Comments

@dappelt
Copy link

dappelt commented Nov 9, 2016

Description

When starting the ledger with an in-memory sqlite database, the database disappears after a few minutes. When the ledger tries to query a (non-existing) table, it crashes.

Steps to reproduce

Open terminal, switch into the root folder of the ledger repo and run

LEDGER_PORT=3001 \
LEDGER_PUBLIC_URI=http://localhost:3001 \
LEDGER_ILP_PREFIX=demo.ledger2. \
LEDGER_DB_URI=sqlite://:memory: \
LEDGER_ADMIN_PASS="mypassword" \
DEBUG=* \
npm start

Wait a few minutes. Then, execute curl http://localhost:3001 and the ledger will fail with:

2016-11-09T11:45:06.321Z error-handler error { Error: SQLITE_ERROR: no such table: L_ACCOUNTS errno: 1, code: 'SQLITE_ERROR' }
2016-11-09T11:45:06.321Z error-handler error Error: SQLITE_ERROR: no such table: L_ACCOUNTS

The problem might be that the connection to the in-memory database is released and, thus, sqlite removes the database. See here.

@justmoon
Copy link
Contributor

This sounds this issue: knex/knex#1701

Note that to reproduce with current ledger you have to access /accounts because the root endpoint no longer accesses the database.

justmoon added a commit that referenced this issue Nov 27, 2016
Change the pool settings for Knex to prevent the database connection
from being cleaned up.

Fixes #354.
@stevenroose
Copy link

stevenroose commented Mar 26, 2017

I tried the same (LEDGER_ADMIN_PASS=mypassword LEDGER_DB_URI=sqlite://:memory: npm start), and I get the same error when doing PUT /accounts/alice:

Unhandled rejection Error: SQLITE_ERROR: no such table: L_ACCOUNTS

@dappelt
Copy link
Author

dappelt commented Mar 27, 2017

Thanks for reporting. Currently, sqlite in-memory databases do not work very reliably with five-bells-ledger. As a workaround, try to store the sqlite database in a file, e.g. LEDGER_ADMIN_PASS=mypassword LEDGER_DB_URI=sqlite:///some/path/ledger.sqlite npm start or use postgres.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants