[{"data":1,"prerenderedAt":229},["ShallowReactive",2],{"blog:2007:sql-server-replication-blocking-on-cleanup-job":3,"blogMore-Technology":215,"comments-sql-server-replication-blocking-on-cleanup-job":228},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"category":11,"tags":12,"excerpt":15,"body":30,"_type":206,"_id":207,"_source":208,"_file":209,"_stem":210,"_extension":211,"url":212,"wordCount":213,"minutes":204,"commentCount":214},"/blog/2007/sql-server-replication-blocking-on-cleanup-job","2007",false,"en","SQL Server replication blocking on cleanup job","For some time my primary workplace has been having a problem with SQL Server replication delaying for several minutes at a time which is surprising given the 12GB of RAM and quad processor hardware behind it.","2007-11-09T16:55:47+00:00","Technology",[13,14],"Microsoft","SQL Server",{"type":16,"children":17},"root",[18,25],{"type":19,"tag":20,"props":21,"children":22},"element","p",{},[23],{"type":24,"value":9},"text",{"type":19,"tag":20,"props":26,"children":27},{},[28],{"type":24,"value":29},"Activity Monitor showed a number of processes on the distribution database used for SQL Server’s replication were blocked by another process which was in turn blocked by a SQL Agent TSQL Job executing on the distribution database.",{"type":16,"children":31,"toc":203},[32,36,40,45,117,146,159,164,184,189,197],{"type":19,"tag":20,"props":33,"children":34},{},[35],{"type":24,"value":9},{"type":19,"tag":20,"props":37,"children":38},{},[39],{"type":24,"value":29},{"type":19,"tag":20,"props":41,"children":42},{},[43],{"type":24,"value":44},"This process’s job GUID that did not match any of our jobs and appeared to be an internal job that regularly executes:",{"type":19,"tag":46,"props":47,"children":52},"pre",{"className":48,"code":49,"language":50,"meta":51,"style":51},"language-sql shiki shiki-themes everforest-light dracula","EXEC dbo.sp_MSdistribution_cleanup @min_distretention = 0, @max_disretention = 32760\n","sql","",[53],{"type":19,"tag":54,"props":55,"children":56},"code",{"__ignoreMap":51},[57],{"type":19,"tag":58,"props":59,"children":62},"span",{"class":60,"line":61},"line",1,[63,69,75,81,86,91,97,103,108,112],{"type":19,"tag":58,"props":64,"children":66},{"style":65},"--shiki-default:#F85552;--shiki-dark:#FF79C6",[67],{"type":24,"value":68},"EXEC",{"type":19,"tag":58,"props":70,"children":72},{"style":71},"--shiki-default:#5C6A72;--shiki-dark:#BD93F9",[73],{"type":24,"value":74}," dbo",{"type":19,"tag":58,"props":76,"children":78},{"style":77},"--shiki-default:#5C6A72;--shiki-dark:#F8F8F2",[79],{"type":24,"value":80},".",{"type":19,"tag":58,"props":82,"children":83},{"style":71},[84],{"type":24,"value":85},"sp_MSdistribution_cleanup",{"type":19,"tag":58,"props":87,"children":88},{"style":77},[89],{"type":24,"value":90}," @min_distretention ",{"type":19,"tag":58,"props":92,"children":94},{"style":93},"--shiki-default:#F57D26;--shiki-dark:#FF79C6",[95],{"type":24,"value":96},"=",{"type":19,"tag":58,"props":98,"children":100},{"style":99},"--shiki-default:#DF69BA;--shiki-dark:#BD93F9",[101],{"type":24,"value":102}," 0",{"type":19,"tag":58,"props":104,"children":105},{"style":77},[106],{"type":24,"value":107},", @max_disretention ",{"type":19,"tag":58,"props":109,"children":110},{"style":93},[111],{"type":24,"value":96},{"type":19,"tag":58,"props":113,"children":114},{"style":99},[115],{"type":24,"value":116}," 32760\n",{"type":19,"tag":20,"props":118,"children":119},{},[120,122,128,130,136,138,144],{"type":24,"value":121},"This would sit on the ",{"type":19,"tag":54,"props":123,"children":125},{"className":124},[],[126],{"type":24,"value":127},"PAGEIOLATCH_SH",{"type":24,"value":129}," status for over 10 minutes at a time most most likely because it was operating on an ",{"type":19,"tag":131,"props":132,"children":133},"em",{},[134],{"type":24,"value":135},"MSrepl_commands",{"type":24,"value":137}," table with 3.4 million records and a ",{"type":19,"tag":54,"props":139,"children":141},{"className":140},[],[142],{"type":24,"value":143},"MSrepl_transactions",{"type":24,"value":145}," table of 600k records.",{"type":19,"tag":20,"props":147,"children":148},{},[149,151,157],{"type":24,"value":150},"The default ",{"type":19,"tag":54,"props":152,"children":154},{"className":153},[],[155],{"type":24,"value":156},"max_disretention",{"type":24,"value":158}," is 72 (hours) and specifies how long to hold the replication history for. This means if a subscriber is down for longer than this period it will lose transactions.",{"type":19,"tag":20,"props":160,"children":161},{},[162],{"type":24,"value":163},"How exactly this system obtained the value 32760 (3.7 years) is a bit of a mystery and I’m assuming that it actually uses a lower value as there have been more than 3.4 million updates in that period.",{"type":19,"tag":20,"props":165,"children":166},{},[167,169,174,176,182],{"type":24,"value":168},"Setting this value to 84 hours (3.5 days) in ",{"type":19,"tag":131,"props":170,"children":171},{},[172],{"type":24,"value":173},"Management Studio’s Replication > Distributor Properties > Transaction Retention",{"type":24,"value":175}," soon dropped those large MS tables down to 406 records and 300 respectively and resulted in ",{"type":19,"tag":54,"props":177,"children":179},{"className":178},[],[180],{"type":24,"value":181},"sp\\_MSdistribution\\_cleanup",{"type":24,"value":183}," executing in a couple of seconds.",{"type":19,"tag":20,"props":185,"children":186},{},[187],{"type":24,"value":188},"It’s a very specific scenario but perhaps this blog post will be of use to somebody else!",{"type":19,"tag":20,"props":190,"children":191},{},[192],{"type":19,"tag":131,"props":193,"children":194},{},[195],{"type":24,"value":196},"[)amien",{"type":19,"tag":198,"props":199,"children":200},"style",{},[201],{"type":24,"value":202},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":51,"searchDepth":204,"depth":204,"links":205},2,[],"markdown","content:blog:2007:sql-server-replication-blocking-on-cleanup-job.md","content","blog/2007/sql-server-replication-blocking-on-cleanup-job.md","blog/2007/sql-server-replication-blocking-on-cleanup-job","md","/blog/2007/sql-server-replication-blocking-on-cleanup-job/",306,0,[216,220,224],{"title":217,"date":218,"url":219},"VTX5000: Part 4 - Communications ","2026-05-06T10:19:24.727Z","/blog/2026/vtx5000-part-4-comms-routines/",{"title":221,"date":222,"url":223},"VTX5000: Part 3 - Software ROM","2026-04-15T23:00:00.000Z","/blog/2026/vtx5000-part-3-software-rom/",{"title":225,"date":226,"url":227},"VTX5000: Part 2 - Hardware","2026-03-30T23:00:00.000Z","/blog/2026/prism-vtx5000-part-2/",[],1779264569723]