@riocrypto/common-server 1.0.2917 → 1.0.2919

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -403,11 +403,22 @@ const buildOrder = (mongoose) => {
403
403
  orderSchema.index({ payoutAutoRetryAt: 1 }, { sparse: true });
404
404
  orderSchema.index({ userId: 1, "TWAP.sessionId": 1, createdAt: 1 });
405
405
  orderSchema.index({ brokerId: 1, "TWAP.sessionId": 1, createdAt: 1 });
406
+ // The stuck order scans (the admin task in admin-tasks and the payout
407
+ // auto-complete in orders) both select on status alone, which no index above
408
+ // has as a prefix, so each run scanned the whole collection. The first serves
409
+ // the side + status pairs the auto-complete looks for, the second gives the
410
+ // admin task its createdAt bound after the status bounds.
411
+ orderSchema.index({ status: 1, side: 1 });
412
+ orderSchema.index({ status: 1, createdAt: 1 });
406
413
  orderSchema.index({ clientReferenceId: 1 }, { sparse: true });
407
414
  orderSchema.index({ "paymentsReceived.blockchainTxId": 1 }, { sparse: true });
408
415
  // At most one order per real quoteId. Imported orders use quoteId "" and are
409
416
  // excluded by the partial filter (which also serves the createOrder lookup).
410
417
  orderSchema.index({ quoteId: 1 }, { unique: true, partialFilterExpression: { quoteId: { $gt: "" } } });
418
+ // Looking up an order by quote matches on quoteId or expiredQuotes in one
419
+ // $or, and an $or falls back to a collection scan unless every branch is
420
+ // indexed. Without this the partial quoteId index above never gets used.
421
+ orderSchema.index({ expiredQuotes: 1 });
411
422
  // At most one order per (broker family, clientReferenceId). rootUserId is
412
423
  // brokerId || userId; orders without a clientReferenceId (or, defensively,
413
424
  // without rootUserId) are excluded from the constraint.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2917",
3
+ "version": "1.0.2919",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",