tiranux commented on code in PR #34168: URL: https://github.com/apache/airflow/pull/34168#discussion_r1347163399
########## airflow/utils/dag_parameters_overflow.py: ########## @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""DAG parameters overflow validator.""" +from __future__ import annotations + +import functools +from typing import TYPE_CHECKING + +from airflow import settings +from airflow.exceptions import AirflowDagTaskOutOfBoundsValue, AirflowException + +if TYPE_CHECKING: + from airflow.models.dag import DAG + + +_POSTGRES_PRIORITY_WEIGHT_UPPER_BOUND = 2147483647 +_POSTGRES_PRIORITY_WEIGHT_LOWER_BOUND = -2147483648 Review Comment: Another drafted idea (needs more thinking) to avoid doing this for a specific column: ```python save_point = session.begin_nested() #create a save point to keep the DagRun, otherwise the exception causes to rollback and lose it try: if hook_is_noop: session.bulk_insert_mappings(TI, tasks) else: session.bulk_save_objects(tasks) for task_type, count in created_counts.items(): Stats.incr(f"task_instance_created_{task_type}", count, tags=self.stats_tags) # Same metric with tagging Stats.incr("task_instance_created", count, tags={**self.stats_tags, "task_type": task_type}) session.flush() except IntegrityError: .. .. except DataError: self.log.info( "Hit DataError while creating the TIs for %s- %s", dag_id, run_id, exc_info=True, ) self.log.info("DataError .......") session.rollback() #it will keep the DAG run so that we can mark it as failed self.log.error("Marking run %s failed", self) self.set_state(DagRunState.FAILED) self.notify_dagrun_state_changed(msg="task_failure") session.flush() ``` One caveat is that the task instance itself will have no logs since it was not inserted in the db. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
