bulltrackers-module 1.0.298 → 1.0.300

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.
@@ -1,9 +1,7 @@
1
1
  /**
2
2
  * FILENAME: computation-system/helpers/computation_dispatcher.js
3
3
  * PURPOSE: "Smart Dispatcher" - Analyzes state, initializes Run Counters, and dispatches tasks.
4
- * UPDATED: Implements Callback Pattern. Initializes 'computation_runs' doc for worker coordination.
5
- * UPDATED: Implements Forensic Crash Analysis & Intelligent Resource Routing.
6
- * FIXED: Implemented "Catch-Up" logic to scan full history (Start -> Target Date) instead of just Target Date.
4
+ * UPDATED: FIXED DEADLOCK by separating concurrency limits for Dates vs Tasks.
7
5
  */
8
6
 
9
7
  const { getExpectedDateStrings, getEarliestDataDates, normalizeName, DEFINITIVE_EARLIEST_DATES } = require('../utils/utils.js');
@@ -39,7 +37,7 @@ async function checkCrashForensics(db, date, pass, computationName) {
39
37
  const lastRSS = data.telemetry.lastMemory.rssMB || 0;
40
38
 
41
39
  if (lastRSS > OOM_THRESHOLD_MB) {
42
- console.log(`[Dispatcher] 🕵️‍♀️ Forensics: ${computationName} likely OOM'd at ${lastRSS}MB. Routing to HIGH-MEM.`);
40
+ // console.log(`[Dispatcher] 🕵️‍♀️ Forensics: ${computationName} likely OOM'd at ${lastRSS}MB. Routing to HIGH-MEM.`);
43
41
  return 'high-mem';
44
42
  }
45
43
  }
@@ -106,10 +104,11 @@ async function dispatchComputationPass(config, dependencies, computationManifest
106
104
  const manifestMap = new Map(computationManifest.map(c => [normalizeName(c.name), c]));
107
105
  const tasksToDispatch = [];
108
106
 
109
- // Concurrency limit for analysis & forensics (Parallelize the historical scan)
110
- const limit = pLimit(20);
107
+ // [FIX] Separate concurrency limits to prevent DEADLOCK
108
+ const dateLimit = pLimit(20); // Parallel Days
109
+ const forensicsLimit = pLimit(50); // Parallel Checks per day
111
110
 
112
- const analysisPromises = allExpectedDates.map(d => limit(async () => {
111
+ const analysisPromises = allExpectedDates.map(d => dateLimit(async () => {
113
112
  try {
114
113
  const fetchPromises = [
115
114
  fetchComputationStatus(d, config, dependencies),
@@ -160,8 +159,8 @@ async function dispatchComputationPass(config, dependencies, computationManifest
160
159
 
161
160
  const validToRun = [...report.runnable, ...report.reRuns];
162
161
 
163
- // [NEW] Parallel Forensics Check
164
- await Promise.all(validToRun.map(item => limit(async () => {
162
+ // [FIX] Use separate 'forensicsLimit' here to avoid deadlock with 'dateLimit'
163
+ await Promise.all(validToRun.map(item => forensicsLimit(async () => {
165
164
  const compName = normalizeName(item.name);
166
165
 
167
166
  // 1. Determine Resource Requirements
@@ -183,6 +182,9 @@ async function dispatchComputationPass(config, dependencies, computationManifest
183
182
  });
184
183
  })));
185
184
 
185
+ // [PROGRESS LOG] This should now fire correctly
186
+ logger.log('INFO', `[Dispatcher] Analyzed ${d}: ${validToRun.length} tasks (Cumulative: ${tasksToDispatch.length})`);
187
+
186
188
  } catch (e) {
187
189
  logger.log('ERROR', `[Dispatcher] Failed analysis for ${d}: ${e.message}`);
188
190
  }
@@ -219,7 +221,7 @@ async function dispatchComputationPass(config, dependencies, computationManifest
219
221
 
220
222
  // 3. Create Audit Ledger Entries
221
223
  const finalDispatched = [];
222
- const txnLimit = pLimit(20);
224
+ const txnLimit = pLimit(50); // Increased txn throughput
223
225
 
224
226
  const txnPromises = tasksToDispatch.map(task => txnLimit(async () => {
225
227
  const ledgerRef = db.collection(`computation_audit_ledger/${task.date}/passes/${task.pass}/tasks`).doc(task.computation);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.298",
3
+ "version": "1.0.300",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [