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 Redshift migrations driver #128

Merged
merged 9 commits into from
Nov 14, 2018
Merged

Conversation

andrei-m
Copy link
Contributor

@andrei-m andrei-m commented Nov 5, 2018

This aims to address #90, specifically the high level plan outlined here: #90 (comment) .

The Redshift driver differs from the Postgres one in that:

  • Distributed locking using advisory locks is not implemented
  • The "redshift" URL scheme is used instead of "postgres"
  • "DELETE FROM" is now used in place of "TRUNCATE", since "TRUNCATE" automatically ends the transaction in Redshift

In addition to unit tests, I ran a basic series of migrations against a real Redshift instance and verified that transaction commit failed in line 0 no longer occurs.

One question: Is it backwards-compatibility problem that the redshift.Redshift no longer has an exported Driver, which was previously an embedded interface? If so, any advice on how to approach that?

Avoid stepping on the 'redshift' driver for the time being. Driver
registration is also modified to identify the clone as 'redshift2'
rather than 'postgres'.
Redshift does not support advisory lock functions. The closest
capability is in-transaction table locks, which aren't quite right here
because the transaction scope is established within SetVersion, not
higher up above the Lock-before/Unlock-after SetVersion.

Local locking is left intact to satisfy expected "can't Lock twice
before Unlocking" behavior asserted in shared tests.
This brings the 'redshift2' package in alignment with the existing
'redshift' package.
Redshift is based on Postgres version 8.0.2.
TRUNCATE commits the current transaction, which breaks the expection of
the 'Commit()' that follows.

See:
golang-migrate#90
https://docs.aws.amazon.com/redshift/latest/dg/r_TRUNCATE.html
This addresses golang-migrate#90 . The
exported Redshift object no longer exports an embedde 'Driver' however,
so some more work is needed to make this backwards compatible.
@coveralls
Copy link

coveralls commented Nov 6, 2018

Pull Request Test Coverage Report for Build 216

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 46.883%

Totals Coverage Status
Change from base Build 210: 0.07%
Covered Lines: 707
Relevant Lines: 1508

💛 - Coveralls

@dhui
Copy link
Member

dhui commented Nov 6, 2018

Is it backwards-compatibility problem that the redshift.Redshift no longer has an exported Driver, which was previously an embedded interface? If so, any advice on how to approach that?

Thanks for calling this out! Not embedding the postgres DB driver would be a backwards incompatible change but I don't know of a valid usecase for directly using an instance of the DB driver or using a DB driver's embeded field. But who knows what every consumer is doing?! I think it's fine to break backwards compatibility in this case since it's unlikely to affect anyone (famous last words)

I don't think it's worth wrapping the new driver to preserve 100% backwards compatibility in this instance. We'll also announce this change in the release notes so in the unlikely event that this change breaks for someone, they'll know how to fix it.

Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

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

I don't have access to a redshift cluster, so I'm relying on the rest of the community to test the changes.

@dhui
Copy link
Member

dhui commented Nov 6, 2018

@andrei-m Thanks for the PR! I'm going to wait a week to see if anyone is concerned about the backwards incompatible change before merging. I'll wait at least another week after that to cut a new release.

@andrei-m
Copy link
Contributor Author

andrei-m commented Nov 6, 2018

Sounds great; thank you.

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.

3 participants