Skip to content

Exclude Bots from Billable Members on SaaS

Mohamed Hamda requested to merge issues/353645/exclude-GitLab-bots into master

What does this MR do and why?

  1. GitLab-generated bots should not count towards billable members on gitlab.com

Query analysis

Users being queried [After/In this MR] Buffer size (Time) [Before/Currently in master] Buffer size (Time)
billed_group_users 24288 (352.475 ms) 24286 (379.777 ms)
billed_project_users 15726 (337.769 ms) 15726 (716.352 ms)
billed_shared_group_users 26616 (333.456 ms) 26614 (712.916 ms)
billed_invited_group_to_project_users 38596 (443.742 ms) 38592 (663.120 ms)

Migration

UP:

main: == 20221210154044 UpdateActiveBillableUsersIndex: migrating ===================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0024s
main: -- index_exists?("users", [:id], {:where=>"((state)::text = 'active'::text) AND ((user_type IS NULL)\nOR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL)\nOR (user_type <> ALL ('{1,2,3,4,5,6,7,8,9,11}'::smallint[])))\n", :name=>"index_users_for_active_billable", :algorithm=>:concurrently})
main:    -> 0.0133s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0004s
main: -- add_index("users", [:id], {:where=>"((state)::text = 'active'::text) AND ((user_type IS NULL)\nOR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL)\nOR (user_type <> ALL ('{1,2,3,4,5,6,7,8,9,11}'::smallint[])))\n", :name=>"index_users_for_active_billable", :algorithm=>:concurrently})
main:    -> 0.0026s
main: -- execute("RESET statement_timeout")
main:    -> 0.0005s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0005s
main: -- indexes("users")
main:    -> 0.0113s
main: -- remove_index("users", {:algorithm=>:concurrently, :name=>"active_billable_users"})
main:    -> 0.0022s
main: == 20221210154044 UpdateActiveBillableUsersIndex: migrated (0.0468s) ==========

Down:

main: == 20221210154044 UpdateActiveBillableUsersIndex: reverting ===================
main: -- transaction_open?()
main:    -> 0.0001s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0023s
main: -- index_exists?("users", [:id], {:where=>"((state)::text = 'active'::text) AND ((user_type IS NULL)\nOR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL)\nOR (user_type <> ALL ('{2,6,1,3,7,8}'::smallint[])))\n", :name=>"active_billable_users", :algorithm=>:concurrently})
main:    -> 0.0114s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0003s
main: -- add_index("users", [:id], {:where=>"((state)::text = 'active'::text) AND ((user_type IS NULL)\nOR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL)\nOR (user_type <> ALL ('{2,6,1,3,7,8}'::smallint[])))\n", :name=>"active_billable_users", :algorithm=>:concurrently})
main:    -> 0.0024s
main: -- execute("RESET statement_timeout")
main:    -> 0.0004s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0005s
main: -- indexes("users")
main:    -> 0.0136s
main: -- remove_index("users", {:algorithm=>:concurrently, :name=>"index_users_for_active_billable"})
main:    -> 0.0021s
main: == 20221210154044 UpdateActiveBillableUsersIndex: reverted (0.0473s) ==========

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Mohamed Hamda

Merge request reports