Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P78808
(An Untitled Masterwork)
Active
Public
Actions
Authored by
Ladsgroup
on Jul 8 2025, 11:36 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Project Tags
None
Referenced Files
F63453985: raw-paste-data.txt
Jul 8 2025, 11:36 AM
2025-07-08 11:36:41 (UTC+0)
Subscribers
None
import
sys
import
yaml
import
glob
from
collections
import
defaultdict
import
dns.resolver
import
pymysql
with
open
(
sys
.
argv
[
1
],
'r'
)
as
f
:
catalog
=
yaml
.
safe_load
(
f
.
read
())
def
get_mediawiki_section_dbname_mapping
(
mw_config_path
,
use_x1
):
db_mapping
=
{}
if
use_x1
:
dblist_section_paths
=
[
mw_config_path
.
rstrip
(
'/'
)
+
'/dblists/all.dblist'
]
else
:
dblist_section_paths
=
glob
.
glob
(
mw_config_path
.
rstrip
(
'/'
)
+
'/dblists/s[0-9]*.dblist'
)
for
dblist_section_path
in
dblist_section_paths
:
with
open
(
dblist_section_path
,
'r'
)
as
f
:
for
db
in
f
.
readlines
():
db_mapping
[
db
.
strip
()]
=
dblist_section_path
.
strip
()
.
rstrip
(
'.dblist'
)
.
split
(
'/'
)[
-
1
]
return
db_mapping
mapping
=
get_mediawiki_section_dbname_mapping
(
'/srv/mediawiki-config'
,
False
)
tables_in_prod
=
defaultdict
(
list
)
tables_catalog
=
set
([
i
[
'name'
]
for
i
in
catalog
[
'tables'
]])
for
wiki_db
in
mapping
:
if
wiki_db
.
startswith
(
'#'
)
or
wiki_db
==
'labtestwiki'
:
continue
ans
=
dns
.
resolver
.
query
(
'_'
+
mapping
[
wiki_db
]
+
'-analytics._tcp.eqiad.wmnet'
,
'SRV'
)[
0
]
conn
=
pymysql
.
connect
(
host
=
str
(
ans
.
target
),
port
=
ans
.
port
,
database
=
wiki_db
,
read_default_file
=
'/etc/mysql/conf.d/analytics-research-client.cnf'
,
autocommit
=
False
)
with
conn
:
with
conn
.
cursor
()
as
cursor
:
cursor
.
execute
(
'show tables;'
)
for
row
in
cursor
.
fetchall
():
if
row
[
0
]
not
in
tables_catalog
:
tables_in_prod
[
row
[
0
]]
.
append
(
wiki_db
)
for
table_name
,
wikis
in
sorted
(
tables_in_prod
.
items
(),
key
=
lambda
i
:
len
(
i
[
1
]),
reverse
=
True
):
print
(
table_name
,
wikis
)
Event Timeline
Ladsgroup
created this paste.
Jul 8 2025, 11:36 AM
2025-07-08 11:36:40 (UTC+0)
Ladsgroup
mentioned this in
T398944: Expand the check of table catalog to detect tables where they shouldn't be
.
Log In to Comment