Skip to content

Parallelize the API calls made to Snowflake during user membership change - #265

Open
Darshikapundir wants to merge 4 commits into
redhat-data-and-ai:mainfrom
Darshikapundir:Parallelize
Open

Parallelize the API calls made to Snowflake during user membership change#265
Darshikapundir wants to merge 4 commits into
redhat-data-and-ai:mainfrom
Darshikapundir:Parallelize

Conversation

@Darshikapundir

Copy link
Copy Markdown
Collaborator

Changes

📝 Description

What changed?

Why is this change needed?

Dependencies

  • N/A

🧪 Testing

Test Coverage

Performance Impact

  • N/A

🚀 Deployment

Deploy Steps

  1. N/A

Prerequisites

  • N/A

Post-Deployment Monitoring

  • N/A

Rollback Plan

  • N/A

⚠️ Breaking Changes

  • This PR contains breaking changes
  • Migration guide provided (if applicable)

Details:

  • N/A

⚙️ Configuration Changes

  • N/A

✅ Developer Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added positive and negative tests that prove my fix is effective or that my feature works
  • Relevant documentation (README, tech specs, etc.) has been added or updated
  • All CI/CD checks are passing

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request optimizes user membership management in Snowflake by introducing parallel processing for API calls. By enabling concurrent execution for user creation, team additions, and team removals, the changes aim to reduce the overall time required for these operations, particularly in scenarios involving a large number of users. A new configurable concurrency limit provides flexibility to fine-tune performance while respecting Snowflake's API rate limits.

Highlights

  • Parallelized Snowflake API Calls: Implemented concurrent execution for Snowflake API calls related to adding and removing users from teams, significantly improving performance for bulk operations.
  • Configurable Concurrency Limit: Introduced a max_concurrency setting for the Snowflake backend, allowing administrators to configure the number of parallel API calls, with a default of 10.
  • Refactored User Creation Logic: The createUsersInBackendAndCache function was refactored to perform user creation in three distinct phases: sequential collection of users to create, parallel execution of CreateUser API calls using errgroup (with the cache lock temporarily released), and sequential updates to the cache.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


Calls fly side by side, Snowflake dances, swift and free, Users join with speed.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces concurrent processing for user creation and team membership operations, primarily targeting the Snowflake backend. It refactors the GroupReconciler to use errgroup for parallelizing backend API calls and adds a configurable max_concurrency setting. The review feedback identifies a critical thread-safety issue where releasing the CacheMutex while accessing shared struct fields creates a race condition. Additionally, the feedback points out that the new concurrency constant is misleadingly named as it affects all backends, a Fivetran-specific role is inappropriately hardcoded in generic logic, and context shadowing in the Snowflake client should be corrected.

Comment thread internal/controller/group_controller.go Outdated
Comment thread internal/controller/group_controller.go Outdated
Comment thread internal/controller/group_controller.go
Comment thread pkg/clients/snowflake/team_membership.go Outdated
@Darshikapundir
Darshikapundir force-pushed the Parallelize branch 3 times, most recently from 1ed6787 to 7946cb2 Compare April 27, 2026 04:28
Signed-off-by: dpundir <dpundir@redhat.com>
Signed-off-by: dpundir <dpundir@redhat.com>
@Darshikapundir
Darshikapundir marked this pull request as ready for review April 27, 2026 05:09
@Darshikapundir Darshikapundir self-assigned this Apr 27, 2026
Comment thread internal/controller/group_controller.go Outdated
Comment thread internal/controller/group_controller.go Outdated
dpundir added 2 commits May 6, 2026 12:40
Signed-off-by: dpundir <dpundir@redhat.com>
Signed-off-by: dpundir <dpundir@redhat.com>
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