Derbyshire 154 for 1 (Godleman 60*) trail Leicestershire 619 (Cosgrove 188, Eckersley 158, Ackerman 118, Mendis 6-204) by 465 runs
Skipper Billy Godleman led a Derbyshire fightback after Leicestershire had passed 600 on the second day of the Division Two County Championship match at Derby.
Godleman marked his 50th first-class appearance for the county with an unbeaten 60 as Derbyshire closed on 154 for 1 in reply to Leicestershire's 619, still 465 behind.
It was a question of how many Leicestershire would score at the start of another hot day and the answer was plenty as Cosgrove and Eckersley plundered 100 in the first hour.
Cosgrove passed his previous best for the county of 156 at Derby two years ago with a pull for four off Tony Palladino and he launched Mendis for two sixes to bring up the 500 before he was caught at long on.
The fourth-wicket stand beat the previous highest for the county against Derbyshire of 207 by Maurice Hallam and Willie Watson in 1959 and there were more records as Leicestershire erased their previous highest score at Derby of 552 for 6 declared 12 years ago.
When Eckersley completed his first hundred of the season from only 91 balls, it was only the 13th time in Leicestershire's history that three batsmen had scored centuries in the same innings and another declaration looked like the only way Derbyshire would get off the field until Eckersley clipped Tom Taylor to deep midwicket.
His departure sparked a collapse that saw the last six wickets go down for 38 with Mendis the main beneficiary of Leicestershire's pursuit of quick runs as he returned the best figures by a Derbyshire legspinner since Kim Barnett, now director of cricket, took 6 for 28 against Glamorgan at Chesterfield in 1991.
It was also the most expensive analysis by a Derbyshire bowler in 113 years although he had bowled 52 overs, 24.3 of them in one spell from the Racecourse end broken only be lunch.
But the most relevant figure for Derbyshire was 470, the runs required to avoid the follow-on, and Slater and Godleman gave them a solid start although both had some narrow escapes before Slater was caught at short leg off Zak Chappell for 42.
Shiv Thakor played and missed several times but hit Chappell for three successive fours although Derbyshire have a lot of batting to do to save the game.