From d4527c4ed7b06a628ca25a31602a0893c5a99993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kami=C5=84ski?= Date: Wed, 23 Oct 2024 21:00:10 +0000 Subject: [PATCH] handle OOM situations --- scripts/data/client.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/scripts/data/client.py b/scripts/data/client.py index e20c851d..b9d70abd 100755 --- a/scripts/data/client.py +++ b/scripts/data/client.py @@ -103,22 +103,31 @@ def process_batch(job): capture_output=True, text=True, ) - + if ( result.returncode != 0 or "FAIL" in result.stdout or "error" in result.stdout or "panicked" in result.stdout ): - logger.error( - f"Error while processing: {job}:\n{result.stdout or result.stderr}" - ) + error = result.stdout or result.stderr + if result.returncode == -9: + match = re.search(r"gas_spent=(\d+)", result.stdout) + gas_info = f", gas spent: {int(match.group(1))}" if match else ", no gas info found" + error = f"Return code -9, killed by OOM?{gas_info}" + message = error + else: + error_match = re.search(r"error='([^']*)'", error) + message = error_match.group(1) if error_match else "" + + logger.error(f"{job} error: {message}") + logger.debug(f"Full error while processing: {job}:\n{error}") else: match = re.search(r"gas_spent=(\d+)", result.stdout) + gas_info = f"gas spent: {int(match.group(1))}" if match else "no gas info found" + logger.info(f"{job} done, {gas_info}") if not match: - logger.warning(f"While processing: {job}: not gas info found") - else: - logger.info(f"{job} processed, gas spent: {int(match.group(1))}") + logger.warning(f"{job}: not gas info found") # Producer function: Generates data and adds jobs to the queue @@ -140,6 +149,9 @@ def job_producer(job_gen): logger.debug("Producer is waiting for weight to be released.") weight_lock.wait() # Wait for the condition to be met + if (current_weight + weight > MAX_WEIGHT_LIMIT) and current_weight == 0: + logger.warning(f"{job} over the weight limit: {MAX_WEIGHT_LIMIT}") + # Add the job to the queue and update the weight job_queue.put((job, weight)) current_weight += weight