Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHARD-1744: Fix for memory leaks in MQ mode #36

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/class/validateData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ export async function validateData(data: Data): Promise<boolean> {
}

if (data.receipt) {
ReceiptLogWriter.writeToLog(`${StringUtils.safeStringify(data.receipt)}\n`)
if (CONFIG.dataLogWrite) {
ReceiptLogWriter.writeToLog(`${StringUtils.safeStringify(data.receipt)}\n`)
}
await processReceiptData([data.receipt])
return true
}
if (data.cycle) {
CycleLogWriter.writeToLog(`${StringUtils.safeStringify(data.cycle)}\n`)
if (CONFIG.dataLogWrite) {
CycleLogWriter.writeToLog(`${StringUtils.safeStringify(data.cycle)}\n`)
}
await insertOrUpdateCycle(data.cycle)
// optimistically upsert blocks for next cycle if it is wrong, it will be corrected in next cycle
await upsertBlocksForCycleCore(
Expand All @@ -63,7 +67,9 @@ export async function validateData(data: Data): Promise<boolean> {
return true
}
if (data.originalTx) {
OriginalTxDataLogWriter.writeToLog(`${StringUtils.safeStringify(data.originalTx)}\n`)
if (CONFIG.dataLogWrite) {
OriginalTxDataLogWriter.writeToLog(`${StringUtils.safeStringify(data.originalTx)}\n`)
}
await processOriginalTxData([data.originalTx])
return true
}
Expand Down
5 changes: 5 additions & 0 deletions src/collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ if (config.env == envEnum.DEV) {
export const startServer = async (): Promise<void> => {
console.log(`Collector Mode: ${CONFIG.collectorMode}`)
overrideDefaultConfig(env, args)
// Exit if dataLogWrite is enabled and collectorMode is MQ
if (CONFIG.dataLogWrite && CONFIG.collectorMode === collectorMode.MQ) {
console.error('ERROR: dataLogWrite must be disabled when running in MQ mode. Please restart the collector with dataLogWrite turned off.')
process.exit(1)
}
// Set crypto hash keys from config
Crypto.setCryptoHashKey(CONFIG.hashKey)

Expand Down
Loading