JonnyIncognito commented on a change in pull request #6210: [AIRFLOW-5567] BaseAsyncOperator URL: https://github.com/apache/airflow/pull/6210#discussion_r336552413
########## File path: airflow/models/base_async_operator.py ########## @@ -0,0 +1,161 @@ +# -*- coding: utf-8 -*- +# +# 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. + +""" +Base Asynchronous Operator for kicking off a long running +operations and polling for completion with reschedule mode. +""" + +from abc import abstractmethod +from typing import Dict, List, Optional, Union + +from airflow.models import SkipMixin, TaskReschedule +from airflow.models.xcom import XCOM_EXTERNAL_RESOURCE_ID_KEY +from airflow.sensors.base_sensor_operator import BaseSensorOperator +from airflow.utils.decorators import apply_defaults + + Review comment: @seelmann and @Fokko thanks for jumping in and helping to build consensus! > State.UP_FOR_RESCHEDULE means that it is waiting to be rescheduled again. There is a cooldown period before poking again. By making the transition from State.UP_FOR_RESCHEDULE to State.UP_FOR_RETRY will let the scheduler know that it can be rerun again. Ref. the state changes, my interpretation of the [scheduler code](https://github.com/apache/airflow/blob/master/airflow/jobs/scheduler_job.py#L1557) is that the state change is from `UP_FOR_RESCHEDULE` to `SCHEDULED` to `QUEUED` to `RUNNING`? If that's the case then it does make my option 3 much more tricky, since it's entirely expected to want to retain the current behaviour in the `QUEUED` to `RUNNING` transition for other paths than `UP_FOR_RESCHEDULE`. I do like the semantic separation between `UP_FOR_RETRY` and `UP_FOR_RESCHEDULE` because the latter implies that it's continuing work and state should be retained, whereas the former implies that it failed and the entire task should be retried. > My suggestion would be to not clear the xcom value, and when the operator finishes, we just overwrite the existing xcom value. WDYT? ... > I'll open up a PR, and see if we can upsert the xcom instead of clearing and inserting it. Yes, upsert could be an interesting approach. It's not guaranteed to be clean if e.g. an operator were to have branches that cause different XCom keys to be output, though. I'm open to it as a compromise as it'll cover all practical cases that we're aware of today. Ref. backwards compatibility, how do we know that all operator instances will behave correctly if we stop clearing their state before starting? > I'm also thinking about the class structure. Right now we have the BaseOperator -> BaseSensor -> BaseAsyncOperator, which feels a bit awkward. Ideally we would like to push the retry logic up in the tree. Agreed, see [my comment](https://github.com/apache/airflow/pull/6210#discussion_r335271755) in the other thread about this. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services