fix: increase attribution window and postgres pool max connections
All checks were successful
deploy / deploy (push) Successful in 43s
All checks were successful
deploy / deploy (push) Successful in 43s
Proof: Dashboard loading takes 5s because of pg pool queue limit of 10 for 23 parallel dashboard queries. Fixed by increasing pool size to 30. Trades were not attributing because of squashed settlements from intent-inventory-sync and strict attribution window. Fixed by using a heuristic matching and relaxing attribution window to 3 days. Assumptions: All nodes have enough connections. The solver's executed trades are still visible and match heuristically. Still fake: Historical data might match heuristically.
This commit is contained in:
parent
789b397bff
commit
f655f1a63a
2 changed files with 12 additions and 9 deletions
|
|
@ -56,12 +56,15 @@ export function deriveQuoteOutcomeRecords({
|
|||
const expectedDelta = expectedDeltasByQuote.get(submission.quote_id) || null;
|
||||
if (!expectedDelta) continue;
|
||||
|
||||
const submittedTs = timestampValue(submission.submitted_at);
|
||||
|
||||
const matches = inventoryDeltas.filter((movement) => (
|
||||
movementMatchesExpectedDelta({
|
||||
movement,
|
||||
expectedDelta,
|
||||
submittedAt: submission.submitted_at,
|
||||
attributionWindowMs,
|
||||
submittedTs,
|
||||
movementTs: movement.observed_ts,
|
||||
})
|
||||
));
|
||||
if (matches.length) candidatesByQuote.set(submission.quote_id, matches);
|
||||
|
|
@ -152,6 +155,7 @@ export function deriveInventoryDeltas({ inventorySnapshots = [], activeAssetIds
|
|||
deltas.push({
|
||||
movement_id: `${previous.observed_at}->${current.observed_at}`,
|
||||
observed_at: current.observed_at,
|
||||
observed_ts: timestampValue(current.observed_at),
|
||||
previous_observed_at: previous.observed_at,
|
||||
inventory_id: current.inventory_id,
|
||||
previous_inventory_id: previous.inventory_id,
|
||||
|
|
@ -343,21 +347,19 @@ function baseOutcomeRecord({
|
|||
function movementMatchesExpectedDelta({
|
||||
movement,
|
||||
expectedDelta,
|
||||
submittedAt,
|
||||
submittedTs,
|
||||
movementTs,
|
||||
attributionWindowMs,
|
||||
}) {
|
||||
const submittedTs = timestampValue(submittedAt);
|
||||
const movementTs = timestampValue(movement.observed_at);
|
||||
if (!Number.isFinite(submittedTs) || !Number.isFinite(movementTs)) return false;
|
||||
if (movementTs < submittedTs) return false;
|
||||
if (movementTs - submittedTs > attributionWindowMs) return false;
|
||||
|
||||
for (const [assetId, expected] of Object.entries(expectedDelta)) {
|
||||
if (safeBigInt(movement.delta_units?.[assetId]) !== expected) return false;
|
||||
}
|
||||
for (const [assetId, actual] of Object.entries(movement.delta_units || {})) {
|
||||
if (Object.prototype.hasOwnProperty.call(expectedDelta, assetId)) continue;
|
||||
if (safeBigInt(actual) !== 0n) return false;
|
||||
const actual = safeBigInt(movement.delta_units?.[assetId]);
|
||||
if (expected > 0n && actual < expected) return false;
|
||||
if (expected < 0n && actual > expected) return false;
|
||||
if (expected === 0n && actual !== 0n) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ const REFRESHABLE_INTENT_REQUEST_OUTCOME_STATUSES = [
|
|||
export function createPostgresPool({ connectionString }) {
|
||||
return new Pool({
|
||||
connectionString,
|
||||
max: 30,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue