ashb commented on a change in pull request #10956:
URL: https://github.com/apache/airflow/pull/10956#discussion_r499878674



##########
File path: airflow/utils/sqlalchemy.py
##########
@@ -141,3 +142,107 @@ def skip_locked(session: Session) -> Dict[str, Any]:
         return {'skip_locked': True}
     else:
         return {}
+
+
+def nowait(session: Session) -> Dict[str, Any]:
+    """
+    Return kwargs for passing to `with_for_update()` suitable for the current 
DB engine version.
+
+    We do this as we document the fact that on DB engines that don't support 
this construct, we do not
+    support/recommend running HA scheduler. If a user ignores this and tries 
anyway everything will still
+    work, just slightly slower in some circumstances.
+
+    Specifically don't emit NOWAIT for MySQL < 8, or MariaDB, neither of which 
support this construct
+
+    See https://jira.mariadb.org/browse/MDEV-13115
+    """
+    dialect = session.bind.dialect
+
+    if dialect.name != "mysql" or dialect.supports_for_update_of:
+        return {'nowait': True}
+    else:
+        return {}
+
+
+def nulls_first(col, session: Session) -> Dict[str, Any]:
+    """
+    Adds a nullsfirst construct to the column ordering. Currently only 
Postgres supports it.
+    In MySQL & Sqlite NULL values are considered lower than any non-NULL 
value, therefore, NULL values
+    appear first when the order is ASC (ascending)
+    """
+    if session.bind.dialect.name == "postgresql":
+        return nullsfirst(col)
+    else:
+        return col
+
+
+USE_ROW_LEVEL_LOCKING: bool = conf.getboolean('scheduler', 
'use_row_level_locking', fallback=True)
+
+
+def with_for_update(query, **kwargs):

Review comment:
       Done in 
https://github.com/apache/airflow/pull/10956/commits/8f357fdf4630df47d4639706516733e0587480dd




----------------------------------------------------------------
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:
[email protected]


Reply via email to