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

@parcel/workers: Invalid argument: MDB_BAD_RSLOT: Invalid reuse of reader #8165

Closed
charIeszhao opened this issue May 29, 2022 · 11 comments · Fixed by #8204
Closed

@parcel/workers: Invalid argument: MDB_BAD_RSLOT: Invalid reuse of reader #8165

charIeszhao opened this issue May 29, 2022 · 11 comments · Fixed by #8204

Comments

@charIeszhao
Copy link

charIeszhao commented May 29, 2022

🐛 bug report

Build randomly failed after upgrading to Parcel 2.6.0

🎛 Configuration (.babelrc, package.json, cli command)

We do not have a babel configuration file in our project, I assume we are using the default config that ships with Parcel.

package.json

...
"devDependencies": {
    "@parcel/core": "2.6.0",
    "@parcel/transformer-sass": "2.6.0",
    "@parcel/transformer-svg-react": "2.6.0",
    "parcel": "2.6.0",
}

CLI commands:

PORT=5001 parcel src/index.html --no-cache --hmr-port 6001

or

parcel build src/index.html --no-autoinstall --no-cache

🤔 Expected Behavior

Build should be successful

😯 Current Behavior

Build failed randomly. If we rerun, most of the time we'll be alright. But it will come again after a while in another CI run. Please refer to the attached stack trace.

@logto/ui: Bundling...
@logto/ui: Packaging & Optimizing...
@logto/ui: @parcel/workers: Invalid argument: MDB_BAD_RSLOT: Invalid reuse of reader 
@logto/ui: locktable slot: The reader lock pid 0 doesn't match env pid 2600
@logto/ui:   Error: Invalid argument: MDB_BAD_RSLOT: Invalid reuse of reader locktable 
@logto/ui:   slot: The reader lock pid 0 doesn't match env pid 2600
@logto/ui:       at LMDBStore.getBinaryFast 
@logto/ui:   (/home/runner/work/logto/logto/node_modules/.pnpm/[email protected]/node_modules/lmdb/dist/index.cjs:1440:12)
@logto/ui:       at LMDBStore.getBinary 
@logto/ui:   (/home/runner/work/logto/logto/node_modules/.pnpm/[email protected]/node_modules/lmdb/dist/index.cjs:1521:27)
@logto/ui:       at LMDBStore.get 
@logto/ui:   (/home/runner/work/logto/logto/node_modules/.pnpm/[email protected]/node_modules/lmdb/dist/index.cjs:1534:17)
@logto/ui:       at LMDBCache.getBlob 
@logto/ui:   (/home/runner/work/logto/logto/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@parcel/cache/lib/LMDBCache.js:119:29)
@logto/ui:       at CommittedAsset.getCode 
@logto/ui:   (/home/runner/work/logto/logto/node_modules/.pnpm/@[email protected]/node_modules/@parcel/core/lib/CommittedAsset.js:80:41)
@logto/ui:       at Asset.getCode 
@logto/ui:   (/home/runner/work/logto/logto/node_modules/.pnpm/@[email protected]/node_modules/@parcel/core/lib/public/Asset.js:154:24)
@logto/ui:       at 
@logto/ui:   /home/runner/work/logto/logto/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:264:52
@logto/ui:       at 
@logto/ui:   /home/runner/work/logto/logto/node_modules/.pnpm/@[email protected]/node_modules/@parcel/utils/lib/index.js:32311:34
@logto/ui:       at $b0fd219fea43bcac$export$2e2bcd8739ae039._runFn 
@logto/ui:   (/home/runner/work/logto/logto/node_modules/.pnpm/@[email protected]/node_modules/@parcel/utils/lib/index.js:32339:19)
@logto/ui:       at $b0fd219fea43bcac$export$2e2bcd8739ae039._next 
@logto/ui:   (/home/runner/work/logto/logto/node_modules/.pnpm/@[email protected]/node_modules/@parcel/utils/lib/index.js:32332:20)
@logto/ui: ✨ Built in 16.10s

💁 Possible Solution

A rerun would probably get around it temporarely.

We downgraded back to 2.5.0 and it's all working as expected

🔦 Context

When we run parcel command to bundle the frontend project, it failed to build.
And it would also fail in our github actions CI

💻 Code Sample

This is the commands we use to trigger parcel:

Local env dev:

PORT=5001 parcel src/index.html --no-cache --hmr-port 6001

CI build:

parcel build src/index.html --no-autoinstall --no-cache

🌍 Your Environment

Software Version(s)
Parcel 2.6.0
Node 16.15.0
npm/Yarn npm 8.5.5
Operating System macOS (local), Ubuntu (CI)
@KillerCodeMonkey
Copy link
Contributor

KillerCodeMonkey commented May 29, 2022

same here. strange, because in my case it only occurs when running multiple parcel builds/watchers with concurrently and only for browser targets.

e.g. i have an electron app - node targets: main, preload, browser: renderer

  • no caching activated for every target

if i run build/watch commands one after one it works, but when i start everything in parallel the browser target is failing with "invalid argument" error every time.

Ubuntu 20.0.4
npm 7
node 16.10.0
parcel 2.6.0

works with same commands and configs with 2.5.0

@mischnic
Copy link
Member

cc @kriszyp

(And sorry in advance for asking for your help two times in the last 24 hours)

kriszyp added a commit to kriszyp/lmdb-js that referenced this issue May 29, 2022
@kriszyp
Copy link
Contributor

kriszyp commented May 30, 2022

tl;dr: I believe [email protected] should fix this.

Thanks @KillerCodeMonkey for this great hint. I believe this may correspond to some other reports, but without any clear way to reproduce. However, running multiple parcel processes in parallel is indeed a surefire way to reproduce. And indeed, this is an issue with multiple process and multiple threads. Basically, when a thread opens the db file to check if it corresponds to another open db file, it was being opened with locks, and opening the same file with multiple lock handles in the same process basically breaks the entire locking scheme. This was fixed by doing this check with a standard read-only open call.

@charIeszhao
Copy link
Author

Thanks everyone.
We do have a monorepo, where multiple web projects are built at the same time and they all use parcel.
So if I understand correctly they just have like a thread deadlock condition... Hmmm, that makes sense.

A patch with a dependency update of [email protected] would fix this, am I right?

@kriszyp
Copy link
Contributor

kriszyp commented May 31, 2022

@demonzoo That's about right (actually kind of the opposite a deadlock, a "no-lock", but yeah, a thread/locking issue). If you are able to manually upgrade/override the lmdb package to verify the fix, prior to the parcel devs committing the upgrade, I'm sure it would be appreciated, (if not possible, that's fine too).

@KillerCodeMonkey
Copy link
Contributor

KillerCodeMonkey commented May 31, 2022

@kriszyp i can confirm: I manually replaced the linux binaries under node_modules/lmdb-linux-x64 with the content of the archive of https://github.com/DoctorEvidence/lmdb-js/releases/tag/v2.4.5 prebuilt-linux.tar worked!

@charIeszhao
Copy link
Author

Thank you, @KillerCodeMonkey . You've been really helpful. Much appreciated!

@evergreen-arslaan-qadus
Copy link

Hey guys just to add, im still struggling with this issue... ive downgraded parcel to 2.2.1 which was the previous version of parcel i was on and im still getting the same issues :(

If it helps, like @KillerCodeMonkey im using:

electron
npm 7.10.0
node 16.0.0
parcel 2.6.0 (also tried 2.5.0 and 2.2.1)

but it seems im just stuck with this issue now. ive tried clearing parcel cache, deleting node_modules, deleting package-lock and the doing a fresh npm ci

any other ideas? i cant exact do what @KillerCodeMonkey suggested with replacing the node_modules because the issue occurs in my ci/cd pipelines when packaging my electron app

i did also try

npm install [email protected] in the hopes that other packages that needed lmdb would use this installed version but it didnt work

Any help would be appreciated!

@KillerCodeMonkey
Copy link
Contributor

@evergreen-arslaan-qadus the issue is open and not resolved. you need to stuck with v2.5.0. what i did was just a quick check if the newer lmbd version would fix the issue. thats it.

you could try using yarn and set resolution of lmdb to v2.4.5

@kriszyp
Copy link
Contributor

kriszyp commented Jun 9, 2022

@evergreen-arslaan-qadus just to show you how it is done on some package managers (certainly not universal nor guaranteed to work):

{
  "dependencies": {
    "parcel": "2.6.0"
  },
  "resolutions": {  <- for yarn
    "lmdb": "2.5.2"
  },
  "overrides": { <- for npm 8
    "lmdb": "2.5.2"
  }
}

(and I don't think you can do any overrides/resolutions with npm 6, not sure about 7).

@evergreen-arslaan-qadus
Copy link

im on npm v7 and it looks like overrides is not supported @kriszyp :(

I actually just managed to come up with a temp fix based off what @KillerCodeMonkey mentioned earlier in the thread, ive changed my build process to build my different render targets sequentially rather than in parallel. for me that fixes it.

i did try to revert to older versions of parcel, i tried 2.5.0 and 2.2.1 (thats the previous one i was on) but for some reason i kept running into the same issue, locally and in my ci/cd pipeline build

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

Successfully merging a pull request may close this issue.

5 participants