potiuk opened a new pull request #19809:
URL: https://github.com/apache/airflow/pull/19809


   There was a side effect caused by the test_start_and_terminate
   from TestStandardRunned that caused broken logging configuration,
   which in turn created OutOfMemory condition for our Public
   GitHubRunners.
   
   The problem was that the test overrode the configuration of
   logging with some simple test configuration, but never restored
   the default configuration, which resulted in `airflow.processor`
   logger that was created before contain empty handlers. Since
   the `airflow.processor` logger has "propagate" set to False,
   empty handlers normally cause a lastResort handler call, which
   by default redirects everything to Stderr and this is what
   happened in DagFile Processor tests. However, DagFileProcessor
   uses `stderr_redirect` which replaces `sys.stderr` with provided
   stream. In this case however the stream set (StreamLogWriter)
   redirected the output to "airflow.processor" logger - which in
   turn (as last resort) redirected everything to sys.stderr which
   in turn redirected everything to "airflow.processor" logger etc.
   
   This resulted in:
   
   * OOM condition in Public GitHub Runners
   * DagFileProcessor failing with exceeded recursion depth when
     there was enough memory to get there.
   
   The condition was triggered by two preceding tests:
   
   1) First test_plugins_manger.py initialized logging for
      `airflow.processor` and stored it in logging manager
   2) The TestStandardTaskRunner test applied simpler configuration
      but the way configure() works - it did not remove the
      "airflow.processor" logger, but it REMOVED all handlers
      registered for it - and never restored the default configuration
   3) The DagFileProcessor logs caused infinite recursion
   
   The fix is two-fold:
   
   * the TestStandardTaskRunner restores default config after test
   * the DagFileProcessor sets default config before starting
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code change, Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in 
[UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.md).
   


-- 
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]


Reply via email to