This is an automated email from the ASF dual-hosted git repository.
kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new 30b8f76 Add logging if an index task unexpectedly has "dirty" objects
to save back to mongo
30b8f76 is described below
commit 30b8f767476612620b3243eadc92b079908d6b61
Author: Dave Brondsema <[email protected]>
AuthorDate: Mon May 10 16:53:28 2021 -0400
Add logging if an index task unexpectedly has "dirty" objects to save back
to mongo
---
Allura/allura/tasks/index_tasks.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/Allura/allura/tasks/index_tasks.py
b/Allura/allura/tasks/index_tasks.py
index a20dcfc..0162f28 100644
--- a/Allura/allura/tasks/index_tasks.py
+++ b/Allura/allura/tasks/index_tasks.py
@@ -49,11 +49,26 @@ def __del_objects(object_solr_ids):
solr_instance.delete(q=solr_query)
+def check_for_dirty_ming_records(msg_prefix, ming_sessions=None):
+ """
+ A debugging helper to diagnose issues with code that unintentionally
modifies records, causing them to be written
+ back to mongo (potentially clobbering values written by a parallel
task/request)
+ """
+ if ming_sessions is None:
+ from allura.model import main_orm_session, artifact_orm_session,
project_orm_session
+ ming_sessions = [main_orm_session, artifact_orm_session,
project_orm_session]
+ for sess in ming_sessions:
+ dirty_objects = list(sess.uow.dirty)
+ if dirty_objects:
+ log.warning(msg_prefix + ' changed objects, causing writes back to
mongo: %s',
+ dirty_objects)
+
@task
def add_projects(project_ids):
from allura.model.project import Project
projects = Project.query.find(dict(_id={'$in': project_ids})).all()
__add_objects(projects)
+ check_for_dirty_ming_records('add_projects task')
@task
@@ -116,6 +131,7 @@ def add_artifacts(ref_ids, update_solr=True,
update_refs=True, solr_hosts=None):
six.reraise(exceptions[0][0], exceptions[0][1], exceptions[0][2])
if exceptions:
raise CompoundError(*exceptions)
+ check_for_dirty_ming_records('add_artifacts task')
@task