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(migration): Make naming constraint fail softer on updates #43357

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

szaimen
Copy link
Contributor

@szaimen szaimen commented Feb 5, 2024

Fix #41253
Fix #43173

Follow-up to #39506

Admin check will be handled in #43432

@szaimen szaimen added bug 2. developing Work in progress labels Feb 5, 2024
@szaimen szaimen added this to the Nextcloud 29 milestone Feb 5, 2024
@szaimen szaimen self-assigned this Feb 5, 2024
@joshtrichards
Copy link
Member

Just logging it for now does seem a practical solution. Seems friendlier and doesn't require a bunch of other engineering.

We could also do this in a setup check maybe? Not sure about resource usage though. The advantage there is we could provide a doc link + further encourage cleanup prior to upgrade runs.

@szaimen szaimen force-pushed the enh/41253/fix-occ-upgrade branch from 1e4cf27 to cc6de72 Compare February 7, 2024 12:24
@szaimen szaimen marked this pull request as ready for review February 7, 2024 12:35
@szaimen szaimen added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Feb 7, 2024
@szaimen
Copy link
Contributor Author

szaimen commented Feb 7, 2024

Just logging it for now does seem a practical solution. Seems friendlier and doesn't require a bunch of other engineering.

We could also do this in a setup check maybe? Not sure about resource usage though. The advantage there is we could provide a doc link + further encourage cleanup prior to upgrade runs.

Yes, this was my idea. :)

The admin check will be handled in #43432

@szaimen
Copy link
Contributor Author

szaimen commented Feb 7, 2024

/backport to stable28

@szaimen szaimen requested review from come-nc, joshtrichards, a team, ArtificialOwl and Altahrim and removed request for a team February 7, 2024 12:36
Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

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

https://github.com/nextcloud/server/blame/cc6de72b11eff0a5b9c7d099281c0ae91afa7320/lib/private/DB/MigrationService.php#L654

Naming constraints:

    • Index, sequence and primary key names must be unique within a Postgres Schema

It will break at least on postgres anyway. To help developers we should just not allow this and always break so they are aware.

Also logging this is of 0 help as no dev checks their logs on CI runs to look for such things.

Definitely a No from me.

@szaimen
Copy link
Contributor Author

szaimen commented Feb 7, 2024

Idea from Joas:

We could weaken it for the update case, to only report in that case, but installing such an app/version/migration must be breaking

Basically similarly to the oracle check we could hand in the sourceSchema

$this->ensureUniqueNamesConstraints($targetSchema);
if ($this->checkOracle) {
$sourceSchema = $this->connection->createSchema();
$this->ensureOracleConstraints($sourceSchema, $targetSchema, strlen($this->connection->getPrefix()));
}

And check if the collision existed there as well already and in that case log the error

nextcloud/server/lib/private/DB/MigrationService.php
Zeile 517 bis 521 (6f39d82)
517 $this->ensureUniqueNamesConstraints($targetSchema);
518 if ($this->checkOracle) {
519 $sourceSchema = $this->connection->createSchema();
520 $this->ensureOracleConstraints($sourceSchema, $targetSchema, strlen($this->connection->getPrefix()));
521 }

@szaimen szaimen added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Feb 7, 2024
Only on installation we want to break hard, so that all developers notice
the bugs when installing the app on any database or CI, and can work on
fixing their migrations before releasing a version incompatible with Postgres.

In case of updates we might be running on production instances and the
administrators being faced with the error would not know how to resolve it
anyway. This can also happen with instances, that had the issue before the
current update, so we don't want to make their life more complicated
than needed.

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen force-pushed the enh/41253/fix-occ-upgrade branch from cc6de72 to 487c33f Compare February 7, 2024 19:47
@nickvergessen nickvergessen changed the title do not break upgrade if index names are not unique fix(migration): Make naming constraint fail softer on updates Feb 7, 2024
@nickvergessen
Copy link
Member

Went for a more simplistic approach now, with hopefully no "production" impact (unless the release is containing a new broken migration), but it still fails hard on installation:

Only on installation we want to break hard, so that all developers notice
the bugs when installing the app on any database or CI, and can work on
fixing their migrations before releasing a version incompatible with Postgres.

In case of updates we might be running on production instances and the
administrators being faced with the error would not know how to resolve it
anyway. This can also happen with instances, that had the issue before the
current update, so we don't want to make their life more complicated
than needed.

@nickvergessen nickvergessen dismissed their stale review February 7, 2024 19:51

Dismissing my review as I did the patch now

@szaimen szaimen added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Feb 8, 2024
@szaimen szaimen merged commit 9e90401 into master Feb 8, 2024
141 checks passed
@szaimen szaimen deleted the enh/41253/fix-occ-upgrade branch February 8, 2024 08:24
@szaimen
Copy link
Contributor Author

szaimen commented Feb 8, 2024

Thanks a lot for your help on this @nickvergessen ! 😊

@szaimen
Copy link
Contributor Author

szaimen commented Feb 8, 2024

/backport to stable28

1 similar comment
@szaimen
Copy link
Contributor Author

szaimen commented Feb 8, 2024

/backport to stable28

artonge pushed a commit that referenced this pull request Feb 8, 2024
fix(migration): Make naming constraint fail softer on updates
joshtrichards added a commit to nextcloud/documentation that referenced this pull request Feb 17, 2024
@blizzz blizzz mentioned this pull request Mar 5, 2024
backportbot bot pushed a commit to nextcloud/documentation that referenced this pull request Mar 7, 2024
acataluddi pushed a commit to acataluddi/nextcloud-documentation that referenced this pull request Apr 28, 2024
Follow-on to nextcloud/server#39506 & nextcloud/server#43357

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Adriano Cataluddi <acataluddi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
6 participants