Skip to content

[AIRFLOW-6416] Sort default connection by conn_id#6987

Merged
potiuk merged 1 commit intoapache:masterfrom
zhongjiajie:db_remove_session_annotation
Jan 5, 2020
Merged

[AIRFLOW-6416] Sort default connection by conn_id#6987
potiuk merged 1 commit intoapache:masterfrom
zhongjiajie:db_remove_session_annotation

Conversation

@zhongjiajie
Copy link
Member

@zhongjiajie zhongjiajie commented Jan 1, 2020

  • Remove unnecessary annotation provide_session
  • Sort create_default_connections by connection id
  • Add sort connection id unittest

@zhongjiajie
Copy link
Member Author

Oh, we already add more probot to repo, Mergeable is good!

@zhongjiajie zhongjiajie force-pushed the db_remove_session_annotation branch from 56ac11e to 21cb5dc Compare January 1, 2020 08:30
@codecov-io
Copy link

codecov-io commented Jan 1, 2020

Codecov Report

Merging #6987 into master will decrease coverage by 0.28%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #6987      +/-   ##
=========================================
- Coverage   84.99%   84.7%   -0.29%     
=========================================
  Files         679     679              
  Lines       38647   38647              
=========================================
- Hits        32847   32737     -110     
- Misses       5800    5910     +110
Impacted Files Coverage Δ
airflow/utils/db.py 100% <100%> (ø) ⬆️
airflow/kubernetes/volume_mount.py 44.44% <0%> (-55.56%) ⬇️
airflow/kubernetes/volume.py 52.94% <0%> (-47.06%) ⬇️
airflow/kubernetes/pod_launcher.py 45.25% <0%> (-46.72%) ⬇️
airflow/kubernetes/refresh_config.py 50.98% <0%> (-23.53%) ⬇️
...rflow/contrib/operators/kubernetes_pod_operator.py 78.75% <0%> (-20%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 869ca96...ccaa6d8. Read the comment docs.

@potiuk
Copy link
Member

potiuk commented Jan 1, 2020

@zhongjiajie why do you want to remove @provide_session ? The way it works now, it will create a new session for each connection - each merge_conn will have a new session (which basically means new connection established with the database). With @provide_sesion, the session will be reused whereas with the new approach it will be create/commit/close for every single Connection entry.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not remove @provide_session as it is there to make all the connections reuse session rather than recreate sessions.

@zhongjiajie
Copy link
Member Author

And we could not remove @provide_session in function merge_conn due to some unittest use it to create temp connections, do we? @potiuk

@zhongjiajie
Copy link
Member Author

zhongjiajie commented Jan 1, 2020

@zhongjiajie why do you want to remove @provide_session ? The way it works now, it will create a new session for each connection - each merge_conn will have a new session (which basically means new connection established with the database). With @provide_sesion, the session will be reused whereas with the new approach it will be create/commit/close for every single Connection entry.

I think we don't need to create connect in function create_default_connections, because it will be create in function merge_conn, so I remove it. but when you comment in

We should not remove @provide_session as it is there to make all the connections reuse session rather than recreate sessions.

I get that point

@potiuk
Copy link
Member

potiuk commented Jan 1, 2020

And we could not remove @provide_session in function merge_conn due to some unittest use it to create temp connections, do we? @potiuk

The @provide_session decorator (and merge_conn uses it) follow exactly the pattern of session/transaction passing. It's there to handle the case that a session is created once, transaction starts, and you reuse the session do everything in the same DB transaction. So it is really needed :)

@zhongjiajie zhongjiajie force-pushed the db_remove_session_annotation branch from 21cb5dc to 4154a3e Compare January 1, 2020 13:09
@zhongjiajie zhongjiajie changed the title [AIRFLOW-6416] Remove DB provide_session and sort by conn_id [AIRFLOW-6416] Sort default connection by conn_id Jan 1, 2020
@kaxil
Copy link
Member

kaxil commented Jan 1, 2020

Do we need this? The connections in the Airflow UI are already sorted.

@zhongjiajie
Copy link
Member Author

zhongjiajie commented Jan 1, 2020

I think it maybe more easy to maintain the code, what do you think? @kaxil

@kaxil
Copy link
Member

kaxil commented Jan 1, 2020

I think it maybe more easy to maintain the code, what do you think? @kaxil

I don't have a strong opinion against it as you might be right it might be good to have it in alphabetical order. WDYT @potiuk ?

@potiuk
Copy link
Member

potiuk commented Jan 1, 2020

No strong opinion - but I think it only makes sense if we enforce it afterwards (like we did with a number of other pre-commit checks). It's low priority I think.

@zhongjiajie
Copy link
Member Author

So what should I do in this situation ? close this PR or do some else? @potiuk @kaxil

* Sort create_default_connections by connection id
* Add sort connection id unittest
@zhongjiajie zhongjiajie force-pushed the db_remove_session_annotation branch from 4154a3e to ccaa6d8 Compare January 5, 2020 16:57
Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you added test for it :)

@potiuk potiuk merged commit 382dd7c into apache:master Jan 5, 2020
@zhongjiajie zhongjiajie deleted the db_remove_session_annotation branch January 6, 2020 02:14
@zhongjiajie
Copy link
Member Author

Thanks Jarek and Kaxil for review

galuszkak pushed a commit to FlyrInc/apache-airflow that referenced this pull request Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments