gitlab-org--gitlab-foss/spec/workers
Yorick Peterse 0395c47193
Migrate events into a new format
This commit migrates events data in such a way that push events are
stored much more efficiently. This is done by creating a shadow table
called "events_for_migration", and a table called "push_event_payloads"
which is used for storing push data of push events. The background
migration in this commit will copy events from the "events" table into
the "events_for_migration" table, push events in will also have a row
created in "push_event_payloads".

This approach allows us to reclaim space in the next release by simply
swapping the "events" and "events_for_migration" tables, then dropping
the old events (now "events_for_migration") table.

The new table structure is also optimised for storage space, and does
not include the unused "title" column nor the "data" column (since this
data is moved to "push_event_payloads").

== Newly Created Events

Newly created events are inserted into both "events" and
"events_for_migration", both using the exact same primary key value. The
table "push_event_payloads" in turn has a foreign key to the _shadow_
table. This removes the need for recreating and validating the foreign
key after swapping the tables. Since the shadow table also has a foreign
key to "projects.id" we also don't have to worry about orphaned rows.

This approach however does require some additional storage as we're
duplicating a portion of the events data for at least 1 release. The
exact amount is hard to estimate, but for GitLab.com this is expected to
be between 10 and 20 GB at most. The background migration in this commit
deliberately does _not_ update the "events" table as doing so would put
a lot of pressure on PostgreSQL's auto vacuuming system.

== Supporting Both Old And New Events

Application code has also been adjusted to support push events using
both the old and new data formats. This is done by creating a PushEvent
class which extends the regular Event class. Using Rails' Single Table
Inheritance system we can ensure the right class is used for the right
data, which in this case is based on the value of `events.action`. To
support displaying old and new data at the same time the PushEvent class
re-defines a few methods of the Event class, falling back to their
original implementations for push events in the old format.

Once all existing events have been migrated the various push event
related methods can be removed from the Event model, and the calls to
`super` can be removed from the methods in the PushEvent model.

The UI and event atom feed have also been slightly changed to better
handle this new setup, fortunately only a few changes were necessary to
make this work.

== API Changes

The API only displays push data of events in the new format. Supporting
both formats in the API is a bit more difficult compared to the UI.
Since the old push data was not really well documented (apart from one
example that used an incorrect "action" nmae) I decided that supporting
both was not worth the effort, especially since events will be migrated
in a few days _and_ new events are created in the correct format.
2017-08-10 17:45:44 +02:00
..
concerns
repository_check Change all :empty_project to :project 2017-08-02 17:47:31 -04:00
authorized_projects_worker_spec.rb Change all :empty_project to :project 2017-08-02 17:47:31 -04:00
background_migration_worker_spec.rb Make it possible to schedule bg migrations in bulk 2017-07-07 15:08:15 +02:00
build_coverage_worker_spec.rb Revert "Enable Style/DotPosition" 2017-02-23 09:33:19 -06:00
build_finished_worker_spec.rb Revert "Enable Style/DotPosition" 2017-02-23 09:33:19 -06:00
build_hooks_worker_spec.rb Revert "Enable Style/DotPosition" 2017-02-23 09:33:19 -06:00
build_success_worker_spec.rb Revert "Enable Style/DotPosition" 2017-02-23 09:33:19 -06:00
create_gpg_signature_worker_spec.rb Change all :empty_project to :project 2017-08-02 17:47:31 -04:00
delete_merged_branches_worker_spec.rb Use :empty_project where possible in worker specs 2017-03-27 18:45:37 -04:00
delete_user_worker_spec.rb Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
email_receiver_worker_spec.rb Don't send rejection mails for all auto-generated mails 2017-08-03 00:40:10 +08:00
emails_on_push_worker_spec.rb Don't include EmailHelpers manually, pick with rspec 2017-08-03 21:55:48 +08:00
every_sidekiq_worker_spec.rb Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
expire_build_artifacts_worker_spec.rb Correct RSpec/SingleLineHook cop offenses 2017-06-14 13:18:56 -05:00
expire_build_instance_artifacts_worker_spec.rb Add many foreign keys to the projects table 2017-07-06 12:01:36 +02:00
expire_job_cache_worker_spec.rb Test the ExpireJobCacheWorker and related changes 2017-05-22 22:07:11 +02:00
expire_pipeline_cache_worker_spec.rb Change all :empty_project to :project 2017-08-02 17:47:31 -04:00
git_garbage_collect_worker_spec.rb Migrate GitGarbageCollectWorker to Gitaly 2017-07-28 17:49:22 +02:00
gitlab_usage_ping_worker_spec.rb Add Conversational Development Index page to admin panel 2017-06-01 17:37:21 +02:00
group_destroy_worker_spec.rb Change all :empty_project to :project 2017-08-02 17:47:31 -04:00
invalid_gpg_signature_update_worker_spec.rb remove log statements from workers 2017-07-27 15:46:04 +02:00
merge_worker_spec.rb Store MergeWorker JID on merge request, and clean up stuck merges 2017-08-07 15:23:37 -03:00
namespaceless_project_destroy_worker_spec.rb Change all :empty_project to :project 2017-08-02 17:47:31 -04:00
new_issue_worker_spec.rb Enable the Layout/SpaceBeforeBlockBraces cop 2017-08-09 11:52:22 +02:00
new_merge_request_worker_spec.rb Enable the Layout/SpaceBeforeBlockBraces cop 2017-08-09 11:52:22 +02:00
new_note_worker_spec.rb Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
pipeline_hooks_worker_spec.rb Revert "Enable Style/DotPosition" 2017-02-23 09:33:19 -06:00
pipeline_metrics_worker_spec.rb Fix specs 2 2017-05-08 11:29:10 -03:00
pipeline_notification_worker_spec.rb Don't include EmailHelpers manually, pick with rspec 2017-08-03 21:55:48 +08:00
pipeline_process_worker_spec.rb Enable RSpec/FilePath cop 2017-04-26 12:50:32 +01:00
pipeline_schedule_worker_spec.rb Enable the Layout/SpaceBeforeBlockBraces cop 2017-08-09 11:52:22 +02:00
pipeline_success_worker_spec.rb Revert "Enable Style/DotPosition" 2017-02-23 09:33:19 -06:00
pipeline_update_worker_spec.rb Revert "Enable Style/DotPosition" 2017-02-23 09:33:19 -06:00
post_receive_spec.rb Enable the Layout/SpaceBeforeBlockBraces cop 2017-08-09 11:52:22 +02:00
process_commit_worker_spec.rb Ensure all project factories use :repository trait or :empty_project 2017-08-01 14:51:52 -04:00
project_cache_worker_spec.rb Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
project_destroy_worker_spec.rb Move exception handling to execute 2017-07-26 12:47:50 +01:00
propagate_service_template_worker_spec.rb Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
prune_old_events_worker_spec.rb Migrate events into a new format 2017-08-10 17:45:44 +02:00
reactive_caching_worker_spec.rb Add a ReactiveCaching concern for use in the KubernetesService 2016-12-19 19:53:03 +00:00
remove_expired_group_links_worker_spec.rb
remove_expired_members_worker_spec.rb Auto-correct RSpec/DescribedClass violations 2017-05-01 11:13:33 -04:00
remove_old_web_hook_logs_worker_spec.rb Implement web hooks logging 2017-05-25 10:07:52 +03:00
remove_unreferenced_lfs_objects_worker_spec.rb Change all :empty_project to :project 2017-08-02 17:47:31 -04:00
repository_fork_worker_spec.rb Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
repository_import_worker_spec.rb Change all :empty_project to :project 2017-08-02 17:47:31 -04:00
schedule_update_user_activity_worker_spec.rb Support multiple Redis instances based on queue type 2017-07-11 03:35:47 +00:00
stuck_ci_jobs_worker_spec.rb Correct RSpec/SingleLineHook cop offenses 2017-06-14 13:18:56 -05:00
stuck_import_jobs_worker_spec.rb Change all :empty_project to :project 2017-08-02 17:47:31 -04:00
stuck_merge_jobs_worker_spec.rb Store MergeWorker JID on merge request, and clean up stuck merges 2017-08-07 15:23:37 -03:00
system_hook_push_worker_spec.rb Moved call of SystemHooksService from UpdateMergeRequestsWorker to GitPushServic… 2017-03-07 12:59:20 +00:00
trending_projects_worker_spec.rb
update_merge_requests_worker_spec.rb Use :empty_project where possible in worker specs 2017-03-27 18:45:37 -04:00
update_user_activity_worker_spec.rb Support multiple Redis instances based on queue type 2017-07-11 03:35:47 +00:00
upload_checksum_worker_spec.rb Add Upload model and UploadChecksumWorker worker 2017-03-06 14:41:09 -05:00
use_key_worker_spec.rb Revert "Enable Style/DotPosition" 2017-02-23 09:33:19 -06:00