Skip to content

[CHORE] Reimplement fork backstop #4511

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

Merged
merged 1 commit into from
May 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion go/pkg/sysdb/coordinator/table_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,10 @@ func (tc *Catalog) ForkCollection(ctx context.Context, forkCollection *model.For
if err != nil {
return err
}

// Defensive backstop to prevent too many forks
if len(lineageFile.Dependencies) > 1000000 {
return common.ErrCollectionTooManyFork
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

The error name ErrCollectionTooManyFork doesn't follow the common Go naming convention for error variables, which typically use plural form for collections. Consider renaming it to ErrCollectionTooManyForks for consistency and clarity.

Comment on lines +970 to +972
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

Consider making the hard-coded limit of 1,000,000 forks configurable through a constant variable at the package level. This would improve maintainability and make it easier to adjust the limit in the future without modifying the function code.

Suggested change
// Defensive backstop to prevent too many forks
if len(lineageFile.Dependencies) > 1000000 {
return common.ErrCollectionTooManyFork
// Defensive backstop to prevent too many forks
if len(lineageFile.Dependencies) > maxAllowedForks {
return common.ErrCollectionTooManyFork
}

Committable suggestion

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

}
lineageFile.Dependencies = append(lineageFile.Dependencies, &coordinatorpb.CollectionVersionDependency{
SourceCollectionId: sourceCollectionIDStr,
SourceCollectionVersion: uint64(sourceCollection.Version),
Expand Down
Loading