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

v0.73.6 has NotNullViolation change in its alembic version #2745

Closed
harshad16 opened this issue Dec 5, 2022 · 5 comments
Closed

v0.73.6 has NotNullViolation change in its alembic version #2745

harshad16 opened this issue Dec 5, 2022 · 5 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. sig/stack-guidance Categorizes an issue or PR as relevant to SIG Stack Guidance.

Comments

@harshad16
Copy link
Member

Bug description

The data sync with the latest storage version v0.73.6 is causing NotNullViolation.

  File "/opt/app-root/lib64/python3.8/site-packages/sqlalchemy/engine/default.py", line 608, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) column "software_environment_id" contains null values

case: op.alter_column("has_symbol", "software_environment_id", existing_type=sa.INTEGER(), nullable=False)
cant be used as psycopg2.errors.NotNullViolation: column "software_environment_id" contains null values

Steps to Reproduce

Steps to reproduce the behavior:

  1. Try schema update with latest alembic version on stage/test cluster dump
  2. See error

Actual behavior

data schema update is failing with NotNull Violation

Expected behavior

smooth data schema update

Environment information

Storage version v0.73.6
revision head: 'bf9ea2a38b01'
database head: '7f7411e247d6'

Additional context

Based on condition https://github.com/thoth-station/storages/blob/master/thoth/storages/graph/postgres.py#L5554, if an external software environment id is present then software environment id is set null.
However

software_environment_id = Column(
software environment id is set primary key,causing the not null issue.

@harshad16 harshad16 added the kind/bug Categorizes issue or PR as related to a bug. label Dec 5, 2022
@goern
Copy link
Member

goern commented Dec 15, 2022

/priority critical-urgent
/assign @mayaCostantini

@sesheta sesheta added the priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. label Dec 15, 2022
@mayaCostantini
Copy link
Contributor

I will look into it, thanks for opening the issue. The implementation I proposed in #2738 should have caused it. What we would need is ideally support for NULL NOT DISTINCT in UniqueConstraint as already proposed in sqlalchemy/sqlalchemy#8240 upstream
I'll try to find an alternative solution in the meantime.

@codificat
Copy link
Member

/sig stack-guidance

@sesheta sesheta added the sig/stack-guidance Categorizes an issue or PR as relevant to SIG Stack Guidance. label Jan 5, 2023
@harshad16 harshad16 assigned harshad16 and unassigned mayaCostantini Jan 9, 2023
@harshad16
Copy link
Member Author

Closing following the tables, it can be noticed that the has_symbol table has details about the software_environment and external_software_environment relationship with version_symbols.
Given that, at once either software_environment or external_software_environment can have a value corresponding to version_symbols in the has_symbol table.

The software_environment_id field in the has_symbol table shouldn't be a primary key.

@harshad16
Copy link
Member Author

With thoth-storages release v0.74.0, the database is able upgrade to revision head: 'bf9ea2a38b01'.
closing this issue as it is resolved on the cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. sig/stack-guidance Categorizes an issue or PR as relevant to SIG Stack Guidance.
Projects
Status: Done
Development

No branches or pull requests

5 participants