-
Notifications
You must be signed in to change notification settings - Fork 32
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
Conversation
lib/destination/ddl/expiry.go
Outdated
nameParts := strings.Split(name, "_") | ||
if len(nameParts) < 2 { | ||
if len(nameParts) < 6 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 6?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the minimum
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
lib/destination/ddl/expiry_test.go
Outdated
tablesToNotDrop := []string{ | ||
"foo", | ||
"transactions", | ||
fmt.Sprintf("expired_tbl__artie_suffix_%d", time.Now().Add(constants.TemporaryTableTTL).Unix()), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup!
lib/destination/ddl/expiry.go
Outdated
return false | ||
} | ||
|
||
unixString := nameParts[len(nameParts)-1] | ||
unix, err := strconv.Atoi(unixString) | ||
tsString := suffixParts[len(suffixParts)-1] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True
Similar logic to
transfer/lib/destination/ddl/ddl.go
Line 22 in 060ed44