##// END OF EJS Templates
Fixing issues of cache invalidation for multiple instances running in rhodecode....
marcink -
r2808:3a007d80 beta
parent child Browse files
Show More
@@ -413,6 +413,11 b' def repo2db_mapper(initial_repo_list, re'
413 raise Exception('Missing administrative account !')
413 raise Exception('Missing administrative account !')
414 added = []
414 added = []
415
415
416 # # clear cache keys
417 # log.debug("Clearing cache keys now...")
418 # CacheInvalidation.clear_cache()
419 # sa.commit()
420
416 for name, repo in initial_repo_list.items():
421 for name, repo in initial_repo_list.items():
417 group = map_groups(name)
422 group = map_groups(name)
418 db_repo = rm.get_by_repo_name(name)
423 db_repo = rm.get_by_repo_name(name)
@@ -438,6 +443,10 b' def repo2db_mapper(initial_repo_list, re'
438 elif install_git_hook:
443 elif install_git_hook:
439 if db_repo.repo_type == 'git':
444 if db_repo.repo_type == 'git':
440 ScmModel().install_git_hook(db_repo.scm_instance)
445 ScmModel().install_git_hook(db_repo.scm_instance)
446 # during starting install all cache keys for all repositories in the
447 # system, this will register all repos and multiple instances
448 key, _prefix, _org_key = CacheInvalidation._get_key(name)
449 CacheInvalidation._get_or_create_key(key, _prefix, _org_key, commit=False)
441 sa.commit()
450 sa.commit()
442 removed = []
451 removed = []
443 if remove_obsolete:
452 if remove_obsolete:
@@ -455,10 +464,6 b' def repo2db_mapper(initial_repo_list, re'
455 log.error(traceback.format_exc())
464 log.error(traceback.format_exc())
456 sa.rollback()
465 sa.rollback()
457
466
458 # clear cache keys
459 log.debug("Clearing cache keys now...")
460 CacheInvalidation.clear_cache()
461 sa.commit()
462 return added, removed
467 return added, removed
463
468
464
469
@@ -1425,13 +1425,14 b' class CacheInvalidation(Base, BaseModel)'
1425 return cls.query().filter(cls.cache_key == key).scalar()
1425 return cls.query().filter(cls.cache_key == key).scalar()
1426
1426
1427 @classmethod
1427 @classmethod
1428 def _get_or_create_key(cls, key, prefix, org_key):
1428 def _get_or_create_key(cls, key, prefix, org_key, commit=True):
1429 inv_obj = Session().query(cls).filter(cls.cache_key == key).scalar()
1429 inv_obj = Session().query(cls).filter(cls.cache_key == key).scalar()
1430 if not inv_obj:
1430 if not inv_obj:
1431 try:
1431 try:
1432 inv_obj = CacheInvalidation(key, org_key)
1432 inv_obj = CacheInvalidation(key, org_key)
1433 Session().add(inv_obj)
1433 Session().add(inv_obj)
1434 Session().commit()
1434 if commit:
1435 Session().commit()
1435 except Exception:
1436 except Exception:
1436 log.error(traceback.format_exc())
1437 log.error(traceback.format_exc())
1437 Session().rollback()
1438 Session().rollback()
General Comments 0
You need to be logged in to leave comments. Login now