Skip to content

Add BulkImports::Tracker

Kassio Borges requested to merge kassio/bulkimport-entity-trackers into master

What does this MR do?

Related to:

This new table is required to support the Group Migration feature. When importing data from another GitLab instance a lot of HTTP/GraphQL requests are done to the source instance to fetch data. Depending on the size of the source, many of these requests will be paginated, BulkImports::Tracker will be used to keep track of what pages were already processed and if the relation still have pages to be processed.

Why the next_page field is not an integer?

The next_page is a text field and not integer is because some of the requests are done over GraphQL, which uses a cursor based pagination, which is a string.

Example

To fetch a group Epics, for instance, we would save something like:

example description relation has_next_page next_page
with graphql epics true eyJpZCI6IjEzNzE5NCJ9
with rest labels true 2
when there's no more pages to fetch milestones false null

Migration

  • CreateBulkImportTracker
$ rails db:migrate:up VERSION=20201104204739
== 20201104204739 CreateBulkImportTrackers: migrating =========================
-- create_table(:bulk_import_trackers)
   -> 0.0087s
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0002s
-- execute("ALTER TABLE bulk_import_trackers\nADD CONSTRAINT check_2d45cae629\nCHECK ( char_length(relation) <= 255 )\nNOT VALID;\n")
   -> 0.0004s
-- current_schema()
   -> 0.0002s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- execute("ALTER TABLE bulk_import_trackers VALIDATE CONSTRAINT check_2d45cae629;")
   -> 0.0004s
-- execute("RESET ALL")
   -> 0.0001s
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0001s
-- execute("ALTER TABLE bulk_import_trackers\nADD CONSTRAINT check_40aeaa600b\nCHECK ( char_length(next_page) <= 255 )\nNOT VALID;\n")
   -> 0.0003s
-- current_schema()
   -> 0.0001s
-- execute("ALTER TABLE bulk_import_trackers VALIDATE CONSTRAINT check_40aeaa600b;")
   -> 0.0004s
== 20201104204739 CreateBulkImportTrackers: migrated (0.0187s) ================

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Kassio Borges

Merge request reports

Loading