fix: replace weight calculation with a rounded ceil #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Looks like we stumbled across a bug in our production middleware that was resulting in some unwarranted internal service errors - looks to us like there's an overflow in the min / max value calculation for random mutually exclusive groups.
I'll use an example from our production code that was giving us trouble to explain the problem.
shortlistedCampaigns
would then have their weights adjusted to 16 based on the following:vwo-node-sdk/lib/utils/DecisionUtil.js
Line 1016 in 16df6eb
3) based on that weight, the following would adjust the lower and upper bounds of
startVariationAllocation
&endVariationAllocation
respectively:vwo-node-sdk/lib/utils/CampaignUtil.js
Line 41 in 16df6eb
4) this all results in a maximum upper bound of
9600
when it comes time to decide on a variation:vwo-node-sdk/lib/core/BucketingService.js
Lines 62 to 64 in 16df6eb
_generateBucketValue
, looks to default to a max of10000
based onConstants.MAX_TRAFFIC_PERCENT
. This leaves a 4% chance that an assigned bucketed value falls outside the acceptable bounds of all active tests in a group and returns null - failing on this line:vwo-node-sdk/lib/utils/DecisionUtil.js
Line 1033 in efee33f
Here's a snapshot of the overflow in action on our production site: