[go: up one dir, main page]

Skip to content

Fix errors that prevents the project deletion process

Summary

A customer reported that when attempting to delete a project, the project was never successfully removed despite a UI confirmation that the project was deleted. This ultimately resulted in a console escalation where the following error was observed.

Relevant logs and/or screenshots

https://sentry.gitlab.net/gitlab/gitlabcom/issues/4012893/?referrer=gitlab_plugin

PG::QueryCanceled: ERROR:  canceling statement due to statement timeout
CONTEXT:  SQL statement "UPDATE ONLY "public"."issues" SET "moved_to_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "moved_to_id""

  lib/gitlab/database/load_balancing/connection_proxy.rb:120:in `block in write_using_load_balancer'
    connection.send(...)
  lib/gitlab/database/load_balancing/load_balancer.rb:122:in `block in read_write'
    yield connection
  lib/gitlab/database/load_balancing/load_balancer.rb:200:in `retry_with_backoff'
    return yield attempt # Yield the current attempt count
  lib/gitlab/database/load_balancing/load_balancer.rb:118:in `read_write'
    retry_with_backoff(attempts: attempts) do |attempt|
  lib/gitlab/database/load_balancing/connection_proxy.rb:119:in `write_using_load_balancer'
    @load_balancer.read_write do |connection|
...
(88 additional frame(s) were not displayed)

ActiveRecord::QueryCanceled: PG::QueryCanceled: ERROR:  canceling statement due to statement timeout
CONTEXT:  SQL statement "UPDATE ONLY "public"."issues" SET "moved_to_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "moved_to_id""

The above error is not the only error that pops up during a user delete, there can be more DELETE query failures, and we can see some of them in https://gitlab.com/gitlab-com/support/internal-requests/-/issues/16765#note_1148499097

Steps to reproduce

  1. Navigate to an affected project
  2. Attempt to delete the project via the UI
  3. Confirm project is not removed

What is the current bug behavior?

Attempts to remove a project are unsuccessful

What is the expected correct behavior?

Users should be able to successfully remove projects

Possible solutions:

  • Instead of depending on the ON DELETE CASCADE at the database level to delete associated records, we could attach dependant: :destroy clause on associations that needs to be deleted and then this method will take care of destroying all such records in batches, thus reducing the chance of a query timeout. See !101098 (diffs) as an example.
  • As an additional step, we should also move the associations that depend ON DELETE SET NULL to dependent: :nullify and add project.nullify_dependent_associations_in_batches
Edited by Manoj M J