Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong Postgres search_path set up instructions #17600

Merged
merged 3 commits into from
Oct 8, 2021

Conversation

tdnguyen6
Copy link
Contributor

In the set up instructions for Postgres database backend, the instructed command for setting search_path to the correct schema lacks public and utility, which prevented SqlAlchemy to find all those required schemas.

In the set up instructions for Postgres database backend, the instructed command for setting search_path to the correct schema lacks `public` and `utility`, which prevented SqlAlchemy to find all those required schemas.
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 13, 2021

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it’s a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@xinbinhuang
Copy link
Contributor

xinbinhuang commented Aug 22, 2021

Thanks for the PR! I like changing username to airflow_user to align with the previous section.

BTW, can you explain why the utility is required? The search_path config can actually vary across deployments because airflow allows you to construct the models in an arbitrary target schema.

@tdnguyen6
Copy link
Contributor Author

tdnguyen6 commented Aug 22, 2021

Regarding the utility search_path, I thought that utility was required because my postgres setup issue was solved with that in the search_path.

After digging a bit more, here is the output of a preconfigured posgresql from airflow official helm chart:

psql (11.12)
Type "help" for help.

postgres=# \dn
  List of schemas
  Name  |  Owner
--------+----------
 public | postgres
(1 row)

postgres=# \dt
                     List of relations
 Schema |             Name              | Type  |  Owner
--------+-------------------------------+-------+----------
 public | ab_permission                 | table | postgres
 public | ab_permission_view            | table | postgres
 public | ab_permission_view_role       | table | postgres
 public | ab_register_user              | table | postgres
 public | ab_role                       | table | postgres
 public | ab_user                       | table | postgres
 public | ab_user_role                  | table | postgres
 public | ab_view_menu                  | table | postgres
 public | alembic_version               | table | postgres
 public | celery_taskmeta               | table | postgres
 public | celery_tasksetmeta            | table | postgres
 public | connection                    | table | postgres
 public | dag                           | table | postgres
 public | dag_code                      | table | postgres
 public | dag_pickle                    | table | postgres
 public | dag_run                       | table | postgres
 public | dag_tag                       | table | postgres
 public | import_error                  | table | postgres
 public | job                           | table | postgres
 public | log                           | table | postgres
 public | rendered_task_instance_fields | table | postgres
 public | sensor_instance               | table | postgres
 public | serialized_dag                | table | postgres
 public | sla_miss                      | table | postgres
 public | slot_pool                     | table | postgres
 public | task_fail                     | table | postgres
 public | task_instance                 | table | postgres
 public | task_reschedule               | table | postgres
 public | variable                      | table | postgres
 public | xcom                          | table | postgres
(30 rows)

postgres=# show search_path;
   search_path
-----------------
 "$user", public
(1 row)

Only public schema is used here, and the search_path is "$user", public, which is the default search_path of every new postgres user.

I have also rechecked with a fresh install of airflow using pip, the default search_path works just fine (psql (PostgreSQL) 12.8 (Ubuntu 12.8-0ubuntu0.20.04.1))

As said above, I agree with you the utility search_path is unnecessary. Moreover, I think this whole step of configuring the search_path is unnecessary as the installation works fine with the default search_path. Nevertheless, I do not guarantee that it works with older versions of Postgres.

@xinbinhuang
Copy link
Contributor

As said above, I agree with you the utility search_path is unnecessary. Moreover, I think this whole step of configuring the search_path is unnecessary as the installation works fine with the default search_path. Nevertheless, I do not guarantee that it works with older versions of Postgres.

You're right. I think the intention of this section is to tell users that if they deploy airflow into a not-default schema, they may need to set the search_path the work properly.

tdnguyen6 and others added 2 commits August 22, 2021 23:46
Co-authored-by: Xinbin Huang <bin.huangxb@gmail.com>
Postgres config: 
The step of configuring the search_path is only necessary when Postgres user's  search_path has been configured to not include public as all airflow tables lie in public schema.
The default search_path is "$user", public, which already contains pubic.
@github-actions
Copy link

github-actions bot commented Oct 7, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Oct 7, 2021
@eladkal eladkal requested a review from xinbinhuang October 7, 2021 05:26
@eladkal eladkal removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Oct 7, 2021
@eladkal eladkal added this to the Airflow 2.2.0 milestone Oct 7, 2021
@eladkal eladkal requested a review from potiuk October 8, 2021 07:07
@potiuk potiuk merged commit 069acde into apache:main Oct 8, 2021
@github-actions
Copy link

github-actions bot commented Oct 8, 2021

The PR is likely ready to be merged. No tests are needed as no important environment files, nor python files were modified by it. However, committers might decide that full test matrix is needed and add the 'full tests needed' label. Then you should rebase it to the latest main or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the okay to merge It's ok to merge this PR as it does not require more tests label Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:documentation okay to merge It's ok to merge this PR as it does not require more tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants