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

Gracefully migrate transactions #262

Merged
merged 2 commits into from
Jul 11, 2024
Merged

Conversation

dogversioning
Copy link
Contributor

@dogversioning dogversioning commented Jul 10, 2024

This PR addresses #259 by altering a given lib_transaction table if an error is raised.

Also added manifest/config to the external API.

Checklist

  • Consider if documentation (like in docs/) needs to be updated
  • Consider if tests should be added
  • Update template repo if there are changes to study configuration

Copy link

github-actions bot commented Jul 10, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
1950 1902 98% 90% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
cumulus_library/init.py 100% 🟢
cumulus_library/databases.py 96% 🟢
cumulus_library/log_utils.py 100% 🟢
TOTAL 99% 🟢

updated for commit: 2abfe1a by action🐍

@dogversioning dogversioning force-pushed the mg/migrate_transactions branch from 7795dab to e4cb339 Compare July 10, 2024 19:58
clear=True,
)
@mock.patch("pyathena.connect")
def test_migrate_transactions_athena(mock_pyathena):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this test is extremely silly.

Comment on lines 93 to 95
except Exception as e:
# Migrating logging tables
if "lib_transactions" in table_name:
Copy link
Contributor

Choose a reason for hiding this comment

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

There's not a tighter exception to grab because of two databases, I assume? I don't suppose this one happens to already fall under the operational_errors() set?

But also, stepping back - this is a pretty awkward code path 😄 -- one that you hadn't even planned to write until I hit this and was grumbling about the UX of it -- if you think this is too gross but you were writing this anyway for my sake, I'd be fine with something as basic as "detect this case, print a nice error message about what to do next" if you didn't want to carry this kind of alter logic going forward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i didn't think of operational_errors - and it might be worth keeping this around if only to actually have something that is using them, since right now they're orphans - the duckdb one is duckdb.duckdb.BinderException, which is pretty broad, but we could add it to this list?

anyway, it's here now, and realistically it's probably going to happen again, so we might as well just ride with 'ok this is where DB migrations go' - this way will preserve state at least, which is different than just dropping, so it is probably 'correct' even if the edge cases are marginal.

Copy link
Contributor

Choose a reason for hiding this comment

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

since right now they're orphans

sql_utils.py uses operational_errors() I think.

anyway, it's here now

Fair - just we might want to give ourselves the grace to chuck it down the line as "deprecated migration stuff" if we ever add more database backends etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sql_utils.py uses operational_errors() I think.

so it does - i don't think that's covered under test yet, which is why that's all #pragma'd up in databases.

@dogversioning dogversioning force-pushed the mg/migrate_transactions branch from c53cb2b to 2abfe1a Compare July 11, 2024 13:33
@dogversioning dogversioning merged commit 5a4b837 into main Jul 11, 2024
3 checks passed
@dogversioning dogversioning deleted the mg/migrate_transactions branch July 11, 2024 13:45
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.

2 participants