Jump to content

User:Razzi/https://phabricator.wikimedia.org/T298505

From Wikitech

https://phabricator.wikimedia.org/T298505

Trying to apply a change to the views.

Before I do this I'd really like to see that the thing isn't there, then apply the change, and see that it is there.

So what is it?

Opening the gerrit patch https://gerrit.wikimedia.org/r/c/operations/puppet/+/743948/ I see

diff --git a/modules/profile/templates/wmcs/db/wikireplicas/maintain-views.yaml b/modules/profile/templates/wmcs/db/wikireplicas/maintain-views.yaml
index bc8f8bf..39b433a 100644
--- a/modules/profile/templates/wmcs/db/wikireplicas/maintain-views.yaml
+++ b/modules/profile/templates/wmcs/db/wikireplicas/maintain-views.yaml
@@ -496,9 +496,9 @@
     view: >
       select gu_id, gu_name, gu_enabled, gu_enabled_method, gu_home_db, NULL as gu_email,
       NULL as gu_email_authenticated, NULL as gu_salt, NULL as gu_password, gu_locked,
-      gu_hidden, gu_registration, NULL as gu_password_reset_key, NULL as gu_password_reset_expiration,
+      gu_hidden, gu_hidden_level, gu_registration, NULL as gu_password_reset_key, NULL as gu_password_reset_expiration,
       NULL as gu_auth_token
-    where: gu_hidden=''
+    where: gu_hidden='' AND gu_hidden_level=0
   ip_changes:
     source:
       - ip_changes
@@ -569,7 +569,7 @@
       - globaluser
     view: >
       select lu_wiki, lu_name, lu_attached_timestamp, lu_attached_method, lu_local_id, lu_global_id
-    where: lu_global_id = gu_id AND gu_hidden=''
+    where: lu_global_id = gu_id AND gu_hidden='' AND gu_hidden_level=0
   logging:
     source: logging
     view: >

Coming from file modules/profile/templates/wmcs/db/wikireplicas/maintain-views.yaml

So it's exposing the field

gu_hidden_level

and requiring it to be 0

for the view to display it.

So in theory, I can run the query select gu_hidden_level from globaluser in cloud labs and it should fail.

Let's try that.

On Portal:Data Services I find a link to Help:Toolforge/Database.

I logged in to quarry and got: https://quarry.wmcloud.org/query/61256

select gu_id from globaluser limit 1;

worked!

Now let's query the new table:

select gu_id, gu_hidden_level from globaluser limit 1;

Unknown column 'gu_hidden_level' in 'field list'

Ok great. Now let's figure out how to apply the change.

One more thing: that was using centralauth_p. Does it work with centralauth ?

No, it doesn't, as expected.

Now it'd be nice to execute the query against the private data to ensure there's no syntax error.

select
    gu_id, gu_name, gu_enabled, gu_enabled_method, gu_home_db,
gu_locked, gu_hidden, gu_hidden_level, gu_registration,
    NULL as gu_email,
    NULL as gu_email_authenticated,
    NULL as gu_salt,
    NULL as gu_password,
    NULL as gu_password_reset_key,
    NULL as gu_password_reset_expiration,
    NULL as gu_auth_token
from globaluser
where
    gu_hidden='' AND gu_hidden_level=0
limit 1

Maybe maintain_views.py has information about where it is run.

So here's the doc about how to update views.

Portal:Data Services/Admin/Wiki Replicas#Updating views

  1. Confirm with DBAs that they don't have work in progress that might interfere

Ok, can post in #wikimedia-data-persistence

  1. Merge associated gerrit change, and force puppet runs on all affected replica servers

Ok, can merge https://gerrit.wikimedia.org/r/c/operations/puppet/+/743948/

  1. On each replica server:

Which replica servers are affected? I suppose any that have centralauth, which is on section S7.

razzi@clouddb1014:~$ sudo mysql -S /var/run/mysqld/mysqld.s7.sock centralauth
puppet $ grep s7 hieradata/hosts/clouddb10*.yaml
hieradata/hosts/clouddb1014.yaml:  s7: 185G
hieradata/hosts/clouddb1018.yaml:  s7: 185G
hieradata/hosts/clouddb1021.yaml:  s7: 50G

so let's start with clouddb1014.yaml. Does my query work?

Yep, it works. Success...

So now, I go into the case where I am modifying an existing view.

  1. If modifying an existing view
    1. depool

https://wikitech.wikimedia.org/wiki/Portal:Data_Services/Admin/Runbooks/Depool_wikireplicas

Ok let's write up a plan