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

More guardrails around ShouldDeleteFromName #842

Merged
merged 6 commits into from
Aug 15, 2024
Merged

Conversation

Tang8330
Copy link
Contributor

@Tang8330 Tang8330 commented Aug 14, 2024

Similar logic to

if strings.Contains(strings.ToLower(tableIdentifier.Table()), constants.ArtiePrefix) {

@Tang8330 Tang8330 marked this pull request as ready for review August 14, 2024 20:34
nameParts := strings.Split(name, "_")
if len(nameParts) < 2 {
if len(nameParts) < 6 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 6?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's just how many are in a temp table

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the minimum

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 could put it back to 2 if it's confusing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see, because right after the table name there are 3 underscores in a row, so 2 of the 6 parts are empty. Maybe it would be more clear to just split the part that comes after the constants.ArtiePrefix and check for 2 parts there? Because otherwise if the table name itself has any underscores in it, we could get a false positive here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danafallon Want to take another look?

tablesToNotDrop := []string{
"foo",
"transactions",
fmt.Sprintf("expired_tbl__artie_suffix_%d", time.Now().Add(constants.TemporaryTableTTL).Unix()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Call this future_tbl__... for clarity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup!

return false
}

unixString := nameParts[len(nameParts)-1]
unix, err := strconv.Atoi(unixString)
tsString := suffixParts[len(suffixParts)-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could just hardcode this to [2] if we're enforcing that len(suffixParts) has to be exactly 3, but I think it's also fine as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True

@Tang8330 Tang8330 merged commit 9178501 into master Aug 15, 2024
3 checks passed
@Tang8330 Tang8330 deleted the more-temp-table-safety branch August 15, 2024 00:55
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