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

Set inventory quantity to a big number may cause out of memory error #3628

Closed
duanhong169 opened this issue Feb 1, 2018 · 3 comments
Closed
Labels
bug For issues that describe a defect or regression in the released software verified reproducible For issues that describe bugs that the core team was able to confirm

Comments

@duanhong169
Copy link
Contributor

duanhong169 commented Feb 1, 2018

Expected behavior

Can publish correctly.

Actual behavior

Server crashed.

Steps to reproduce the behavior

  1. Login as shop owner
  2. Edit a product variant
  3. Set inventory quantity to a big number(e.g. 1000000000)
  4. Click 'Publish'

Versions

1.7.0

Related code

while (i <= newQty) {
const id = Inventory._makeNewID();
batch.insert({
_id: id,
productId,
variantId: variant._id,
shopId: product.shopId,
createdAt: new Date(),
updatedAt: new Date(),
workflow: { // we add this line because `batchInsert` doesn't know
status: "new" // about SimpleSchema, so `defaultValue` will not
}
});
i++;
}

Crash log

Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: <--- Last few GCs --->
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: [7775:0x26b9430]   951501 ms: Mark-sweep 1400.8 (1473.4) -> 1400.8 (1473.4) MB, 1364.2 / 0.0 ms  allocation failure GC in old space requested
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: [7775:0x26b9430]   952965 ms: Mark-sweep 1400.8 (1473.4) -> 1400.7 (1443.4) MB, 1461.5 / 0.0 ms  last resort GC in old space requested
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: [7775:0x26b9430]   954530 ms: Mark-sweep 1400.7 (1443.4) -> 1400.7 (1443.4) MB, 1564.5 / 0.0 ms  last resort GC in old space requested
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: <--- JS stacktrace --->
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: ==== JS stack trace =========================================
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: Security context: 0x2f5c4bf25e91 <JSObject>
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: 1: _registerInventory(aka _registerInventory) [/home/remote/build/bundle/programs/server/app/app.js:~54457] [pc=0x30e0a3dcb8d5](this=0x3f1999a02311 <undefined>,product=0x11be82d2bce9 <Object map = 0xd3133365049>)
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: 3: inventoryRegister [/home/remote/build/bundle/programs/server/app/app.js:54679] [bytecode=0x11be82d2be01 offset=67](this=0x17788884d001 <JSObject>,product=0x11be82d2bce9 <Obje...
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: 1: node::Abort() [/usr/local/bin/node]
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: 2: 0x121809c [/usr/local/bin/node]
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: 3: v8::Utils::ReportOOMFailure(char const*, bool) [/usr/local/bin/node]
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: 5: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: 6: v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
Feb 01 14:53:41 iZrj90nq43piiv539ao8fyZ xxxx[7775]: 7: 0x30e0a390463d
@prinzdezibel prinzdezibel added verified reproducible For issues that describe bugs that the core team was able to confirm bug For issues that describe a defect or regression in the released software labels Feb 2, 2018
@prinzdezibel prinzdezibel self-assigned this Feb 2, 2018
@prinzdezibel
Copy link
Contributor

Talked to Brent about this, mainly to get an idea why every instance of a product get its own document in db. Under the assumption that we really want to keep this as it is (i.e. one document for each instance), I would propose to arbitrarily constrain the highest inventory amount to say "1000000". Not sure if there's a valid use case to allow values of 1 billion or higher. But that's just a first proposal, maybe others have better ideas.

@brent-hoover
Copy link
Collaborator

Since the use case for this is pretty limited, I would consider this a low-impact bug and thus a lower priority

@aldeed
Copy link
Contributor

aldeed commented Jul 11, 2019

Fixed in 2.0.0

@aldeed aldeed closed this as completed Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For issues that describe a defect or regression in the released software verified reproducible For issues that describe bugs that the core team was able to confirm
Projects
None yet
Development

No branches or pull requests

5 participants