Skip to content

GitLab Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
GitLab
GitLab
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 35,957
    • Issues 35,957
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 1,285
    • Merge Requests 1,285
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Metrics
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • GitLabGitLab
  • Issues
  • #196169

Closed
Open
Opened Jan 10, 2020 by Matthias Käppler@mkaeppler🔴Maintainer

Bulk inserts: Consider disallowing callback definitions

This was broken out of #36992 (closed) after reviewing the first POC in a debrief meeting.

The main problem with the POC was the difficulty of firing AR callbacks in a reliable way before and after batching the SQL. An obvious solution out of this is: no callbacks, no problem. To that end we suggest that if we were able (and willing) to identify certain "offenders" we know to perform particularly bad during imports, then we could add a guard that prevents developers from defining any AR callbacks on them to begin with. That way, we can then provide a dedicated code path for those relations during import where we simple batch-insert them row-wise, possibly bypassing AR altogether.

This has drawbacks as well of course, such as:

  • the inability to define callbacks on certain relations but not others may be surprising to developers
  • it would increase the complexity of the importer, since we would have to account for both batched inserts and "normal" inserts

The current proposal is to define a new concern BulkInsertable that "white lists" a given relation to be permitted for bulk inserts as described in #196844 (closed). Upon inclusion of that mixin it would perform checks to verify that the model is actually bulk-insertable by not defining any custom callbacks or validations.

Edited Jan 27, 2020 by Matthias Käppler
Assignee
Assign to
12.8
Milestone
12.8 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: gitlab-org/gitlab#196169