|
a/scripts/refresh-all-repos.py |
|
b/scripts/refresh-all-repos.py |
1 |
import argparse
|
1 |
import argparse
|
2 |
import logging
|
2 |
import logging
|
|
|
3 |
import re
|
3 |
|
4 |
|
4 |
import faulthandler
|
5 |
import faulthandler
|
5 |
from pylons import c
|
6 |
from pylons import c
|
6 |
from ming.orm import ThreadLocalORMSession
|
7 |
from ming.orm import ThreadLocalORMSession
|
7 |
|
8 |
|
|
... |
|
... |
67 |
|
68 |
|
68 |
i = M.repo.CommitDoc.m.find({"_id": {"$in": ci_ids}}).count()
|
69 |
i = M.repo.CommitDoc.m.find({"_id": {"$in": ci_ids}}).count()
|
69 |
log.info("Deleting %i CommitDoc docs...", i)
|
70 |
log.info("Deleting %i CommitDoc docs...", i)
|
70 |
M.repo.CommitDoc.m.remove({"_id": {"$in": ci_ids}})
|
71 |
M.repo.CommitDoc.m.remove({"_id": {"$in": ci_ids}})
|
71 |
|
72 |
|
72 |
i = M.repo.TreesDoc.m.find({"_id": {"$in": ci_ids}}).count()
|
|
|
73 |
log.info("Deleting %i TreesDoc docs...", i)
|
|
|
74 |
M.repo.TreesDoc.m.remove({"_id": {"$in": ci_ids}})
|
|
|
75 |
|
|
|
76 |
# delete these in chunks, otherwise the query doc can
|
73 |
# delete these in chunks, otherwise the query doc can
|
77 |
# exceed the max BSON size limit (16MB at the moment)
|
74 |
# exceed the max BSON size limit (16MB at the moment)
|
78 |
for tree_ids_chunk in chunked_list(tree_ids, 300000):
|
75 |
for tree_ids_chunk in chunked_list(tree_ids, 300000):
|
79 |
i = M.repo.TreeDoc.m.find({"_id": {"$in": tree_ids_chunk}}).count()
|
76 |
i = M.repo.TreeDoc.m.find({"_id": {"$in": tree_ids_chunk}}).count()
|
80 |
log.info("Deleting %i TreeDoc docs...", i)
|
77 |
log.info("Deleting %i TreeDoc docs...", i)
|
81 |
M.repo.TreeDoc.m.remove({"_id": {"$in": tree_ids_chunk}})
|
78 |
M.repo.TreeDoc.m.remove({"_id": {"$in": tree_ids_chunk}})
|
82 |
i = M.repo.LastCommitDoc.m.find({"object_id": {"$in": tree_ids_chunk}}).count()
|
79 |
i = M.repo.LastCommitDoc.m.find({"object_id": {"$in": tree_ids_chunk}}).count()
|
83 |
log.info("Deleting %i LastCommitDoc docs...", i)
|
80 |
log.info("Deleting %i LastCommitDoc docs...", i)
|
84 |
M.repo.LastCommitDoc.m.remove({"object_id": {"$in": tree_ids_chunk}})
|
81 |
M.repo.LastCommitDoc.m.remove({"object_id": {"$in": tree_ids_chunk}})
|
85 |
del tree_ids
|
82 |
del tree_ids
|
|
|
83 |
|
|
|
84 |
# delete these after TreeDoc and LastCommitDoc so that if
|
|
|
85 |
# we crash, we don't lose the ability to delete those
|
|
|
86 |
i = M.repo.TreesDoc.m.find({"_id": {"$in": ci_ids}}).count()
|
|
|
87 |
log.info("Deleting %i TreesDoc docs...", i)
|
|
|
88 |
M.repo.TreesDoc.m.remove({"_id": {"$in": ci_ids}})
|
|
|
89 |
|
|
|
90 |
# delete LastCommitDocs for non-trees
|
|
|
91 |
repo_lastcommit_re = re.compile("^{}:".format(c.app.repo._id))
|
|
|
92 |
i = M.repo.LastCommitDoc.m.find(dict(_id=repo_lastcommit_re)).count()
|
|
|
93 |
log.info("Deleting %i remaining LastCommitDoc docs, by repo id...", i)
|
|
|
94 |
M.repo.LastCommitDoc.m.remove(dict(_id=repo_lastcommit_re))
|
86 |
|
95 |
|
87 |
i = M.repo.DiffInfoDoc.m.find({"_id": {"$in": ci_ids}}).count()
|
96 |
i = M.repo.DiffInfoDoc.m.find({"_id": {"$in": ci_ids}}).count()
|
88 |
log.info("Deleting %i DiffInfoDoc docs...", i)
|
97 |
log.info("Deleting %i DiffInfoDoc docs...", i)
|
89 |
M.repo.DiffInfoDoc.m.remove({"_id": {"$in": ci_ids}})
|
98 |
M.repo.DiffInfoDoc.m.remove({"_id": {"$in": ci_ids}})
|
90 |
|
99 |
|