Smart segment cannot reach data

I have created two smart segments for a collection. Both segment filter a property value which is status.
First segment filters records with status equal to 1 and second segment filters records with status equal to 2.

Both segments work perfectly fine in dev mode but not in production mode. In production mode, the second segment cannot reach data.

Here are the screenshot of the failing request on the second segment:

As you can see those requests work perfectly fine on the first segment in production:

Here is the code for the failing segment:

{
  name: '1er paiement validé',
  where: async () => {
    const payments = await Payment.find({
      'schedules.0.status': 2
    })

    return { _id: { $in: payments.map(payment => payment.orderId) } }
  }
}

Here is the code for the working segment:

{
  name: '1er paiement en attente',
  where: async () => {
    const payments = await Payment.find({
      'schedules.0.status': 1
    })

    return { _id: { $in: payments.map(payment => payment.orderId) } }
  }
}
 "meta": {
    "database_type": "MongoDB",
    "liana": "forest-express-mongoose",
    "liana_version": "6.3.8",
    "engine": "nodejs",
    "engine_version": "12.20.0",
    "framework": "other",
    "framework_version": null,
    "orm_version": "5.9.4"
  }

Can you help me fix this?

Hi @guillaumejauffret,

Can you please, just for a test, to put ‘2’ instead of ‘1’ inside the enum status, in the working smart segment?
Then you should have a “1er paiement en attente” segment that will display you the “validé records”. Or it may fail, that would be interesting to know.
It’s curious that a different value makes the segment fail.

ok @Sliman_Medini . good idea. I test that

@Sliman_Medini I still have the problem.

Hello @guillaumejauffret,

Can you tell me a bit more about the test you just tried?
Having the exact same code for both segments (except the name) still fails for the second one?

Best,

Hi @Guillaume_Cisco,

yes I have the exact same code for both segments except for the name and the value of the status on which I filter records.

When I pass 2 as value of the status, the segment cannot load data. Is there a problem a too large request results?

Thank you for this answer @guillaumejauffret.
I just want to be sure, if you specify the exact same code and the same value 1, and only name is different, does it work? If yes, we will be able to eliminate one thing.

If only the value makes it fails, we now have a clue about a process failure due to this specific value.
It can be as you say a problem with too large request results or something else.

Let me know :slight_smile:

Do you have any logs to share for helping us solving this case?

Thank you,

I try this and look for relevant logs

hi @Guillaume_Cisco,

I specified the exact same code and the same value 1 and it worked fine.

Looking at the logs in prod when value is 2, here is what I see.

It seems we lack of Javascript memory, so we increased the memory up to 1GO and the request worked. However, I am wondering how we can have control over that because I am not sure It cannot happen again.

Do you have any idea?

Hello @guillaumejauffret,

There is currently no pagination / limitation in your segment definition.

Given the segment definition you pasted, I suggest you create a “simple” segment via the collection settings in Forest Admin. This will handle pagination for you.

Hope this helps.