Skip to content

Remove substransaction from wiki event creation

Max Woolf requested to merge 338923-event-subtransaction-removal into master

What does this MR do?

  • Removes the use of a subtransactions when creating an Event object for a change to a wiki.

Console Output

Before

  User Load (0.6ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application:console,line:(pry):18:in `__pry__'*/
  Event Load (0.5ms)  SELECT "events".* FROM "events" WHERE "events"."target_type" = 'WikiPage::Meta' AND "events"."target_id" = 2 AND "events"."fingerprint" = '\x4468e5deabf5e6d0740cd1a77df56f67093ec943' LIMIT 1 /*application:console,line:/app/services/event_create_service.rb:124:in `wiki_event'*/
  TRANSACTION (0.2ms)  BEGIN /*application:console,line:/app/models/application_record.rb:69:in `block in safe_find_or_create_by'*/
  Event Load (0.4ms)  SELECT "events".* FROM "events" WHERE "events"."action" = 1 AND "events"."author_id" = 1000046 AND "events"."fingerprint" = '\x4468e5deabf5e6d0740cd1a77df56f67093ec943' AND "events"."target_id" = 2 AND "events"."target_type" = 'OpenStruct' LIMIT 1 /*application:console,line:/app/models/application_record.rb:69:in `block in safe_find_or_create_by'*/
  TRANSACTION (0.2ms)  COMMIT /*application:console,line:/lib/gitlab/database.rb:235:in `commit'*/

After

  User Load (0.5ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application:console,line:(pry):20:in `__pry__'*/
  Event Load (0.3ms)  SELECT "events".* FROM "events" WHERE "events"."target_type" = 'WikiPage::Meta' AND "events"."target_id" = 2 AND "events"."fingerprint" = '\x4468e5deabf5e6d0740cd1a77df56f67093ec943' LIMIT 1 /*application:console,line:/app/services/event_create_service.rb:124:in `wiki_event'*/
  Event Load (0.3ms)  SELECT "events".* FROM "events" WHERE "events"."action" = 1 AND "events"."author_id" = 1000046 AND "events"."fingerprint" = '\x4468e5deabf5e6d0740cd1a77df56f67093ec943' AND "events"."target_id" = 2 AND "events"."target_type" = 'OpenStruct' LIMIT 1 /*application:console,line:/app/services/event_create_service.rb:201:in `create_event'*/

Screenshots or Screencasts (strongly suggested)

How to setup and validate locally (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • [-] 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

Related to #338923 (closed)

Edited by Mayra Cabrera

Merge request reports

Loading