Skip to content

Fix: consensus detection OOMs the analytics container on a username join - #14

Open
mpont91 wants to merge 1 commit into
ent0n29:mainfrom
mpont91:fix/consensus-oom
Open

Fix: consensus detection OOMs the analytics container on a username join#14
mpont91 wants to merge 1 commit into
ent0n29:mainfrom
mpont91:fix/consensus-oom

Conversation

@mpont91

@mpont91 mpont91 commented Aug 27, 2026

Copy link
Copy Markdown

ConsensusDetector._get_smart_money_trades joins the trades of one market to the scored traders on username:

FROM polybot.aware_global_trades t
INNER JOIN (
    SELECT username, total_score
    FROM polybot.aware_smart_money_scores FINAL
    WHERE total_score >= {min_total_score}
) s ON t.username = s.username

Practically no Polymarket wallet has a username set. On a live instance all 1,793 scored traders above the threshold have it empty, and so do almost all trades. The join therefore matches empty string to empty string and becomes a cartesian product.

Measured on the busiest market of the last 48 hours:

join on username        15,267,395 rows
join on proxy_address            the handful that are real

There is no LIMIT, and every row is materialised into a Python dict. The loop then repeats for ~100 markets.

Effect

The container is OOM-killed part way through consensus on every run. On the instance where I found this: RestartCount 56, and grep -c "AWARE Analytics - Complete" over the entire log returns 0 — no cycle has ever finished.

Consensus is step 7 of 12, so everything after it has never run: ML enrichment, edge persistence, drift monitoring, notification dispatch, and the strategy P&L job. Any dashboard fed by those tables shows whatever was last written by a manual run.

Fix

Join on proxy_address, which is always populated and is the key the rest of the scoring pipeline uses. _aggregate_positions is keyed on the address too — keyed on an empty username it collapsed every trader into a single bucket, so the trader count behind a signal was meaningless.

After the fix the same pipeline completes in 70.6s.

The per-market query joined trades to scores on username, which is empty
for every scored wallet, producing a cartesian product of 15M rows for a
single busy market. Joined on proxy_address instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant