Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-11-18 16:39:06 +0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2016-11-19 00:55:44 +0300
commit673e76073ea889fa10c66823f1780e745f501182 (patch)
tree4fbe8be54936ca3d0772df84182ea0dbd5d86638 /db
parent7835d99cf9052893069a8f4f19184278cca70459 (diff)
Merge branch '23223-group-deletion-race-condition' into 'master'
Remove race condition while deleting groups ## What does this MR do? The intended flow during a group deletion is: ``` Soft-delete group (sync) -> Delete group projects (async) -> Hard-delete group (async) ``` The soft-delete was run in a transaction, which was committed only after the async job (for hard-deletion) was kicked off. There was a race condition here - the soft-delete transaction could complete _after_ the hard delete completed, leaving a soft-deleted record in the database. This MR removes this race condition. There is no need to run the soft-delete in a transaction. The soft-delete completes before the async job is kicked off. This MR also adds a migration to delete all existing (soft-deleted) groups left in an inconsistent state due to this bug. - Closes #23223 - EE merge request: gitlab-org/gitlab-ee!886 See merge request !7528
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20161117114805_remove_undeleted_groups.rb16
-rw-r--r--db/schema.rb2
2 files changed, 17 insertions, 1 deletions
diff --git a/db/migrate/20161117114805_remove_undeleted_groups.rb b/db/migrate/20161117114805_remove_undeleted_groups.rb
new file mode 100644
index 00000000000..ebc2d974ae0
--- /dev/null
+++ b/db/migrate/20161117114805_remove_undeleted_groups.rb
@@ -0,0 +1,16 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class RemoveUndeletedGroups < ActiveRecord::Migration
+ DOWNTIME = false
+
+ def up
+ execute "DELETE FROM namespaces WHERE deleted_at IS NOT NULL;"
+ end
+
+ def down
+ # This is an irreversible migration;
+ # If someone is trying to rollback for other reasons, we should not throw an Exception.
+ # raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 42cf9515860..db2ce689afc 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20161113184239) do
+ActiveRecord::Schema.define(version: 20161117114805) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"