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

Workaround for infinite loop in SQLite 3.38 / Update to 3.38.4 #802

Closed
kryops opened this issue May 3, 2022 · 4 comments · Fixed by #808
Closed

Workaround for infinite loop in SQLite 3.38 / Update to 3.38.4 #802

kryops opened this issue May 3, 2022 · 4 comments · Fixed by #808

Comments

@kryops
Copy link

kryops commented May 3, 2022

Hi there,

I seem to have discovered an infinite loop in SQLite 3.38: https://sqlite.org/forum/forumpost/2482b32700384a0f

The workaround described is disable the new bloom filter optimization:

sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, db, 0x100000);

Is there any way that we can set this from the outside using better-sqlite3? Or would you be willing to publish a release that includes this workaround until a fixed version of SQLite is out?

The alternative for us would be downgrading to better-sqlite3@7.5.0, but that leads to electron/rebuild#1005 in one of our builds because that version has no prebuilt binaries for Electron 18 😕

Thanks for your support!


EDIT: 3.38.4 is out with the fix, see comment below

@notBald
Copy link

notBald commented May 4, 2022

You don't need prebuilt binaries. If you're on Windows, install Node with the bundled build tools (it's a checkbox during the installation) open a command prompt and navigate to the Better SQlite3 folder in node_modules.

Run these commands:
npm i node-abi@latest
npm i --save-dev node-gyp@latest
npm i --build-from-source --dist-url=https://electronjs.org/headers --target=18.2.0

Where --target=18.2.0 is the Electron version.

If you wish to use a different version of SQLite, download the amalgamation of said version and place the source files (sqlite3.c and friends) in the "better-sqlite3\deps\sqlite3" folder.

If you're using Electron Builder, you may have to turn off npmRebuild in the electron-builder configuration file. If you don't it will download the prebuilt binary, overwriting the one you made.

(Note, node-gyp is a little troublesome. It can't handle spaces in paths, so make sure your project doesn't sit in a folder that has a space. If I recall right, node-gyp also needs Python installed. So install the latest version of Python.)

@kryops
Copy link
Author

kryops commented May 4, 2022

Unfortunately, it is not that easy - we have a legacy build on a CI system using a (very large and very brittle) Windows Docker image that includes an apparently too old version of MSBuild. Getting binaries for Electron 18 to build there would probably take longer than migrating to our newer Docker image (which includes other changes that we would need to backport in our application) - and once we do that, we could just downgrade to better-sqlite3@7.5.0 again to work around the SQLite bug 😅

@kryops kryops changed the title Workaround for infinite loop in SQLite 3.38 Workaround for infinite loop in SQLite 3.38 / Update to 3.38.4 May 5, 2022
@kryops
Copy link
Author

kryops commented May 5, 2022

SQLite released the fix for the infinite loop in 3.38.4. Would you be willing to publish a release with the update?

Thanks so much ☺️

@mudgen
Copy link

mudgen commented May 9, 2022

I am also interested in using SQLite version 3.38.4.

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

Successfully merging a pull request may close this issue.

3 participants