On May 15 at AT&T Park, in an 8–4 win over the Los Angeles Dodgers, Cain surpassed two thousand career innings pitched. Cain becomes the twelfth pitcher in franchise history and joins Hall of Famers Juan Marichal and Gaylord Perry as the only three pitchers in the San Francisco Era to reach the milestone. On July 24 at AT&T Park against the Pittsburgh Pirates, Cain struck out his 1,678th career batter, surpassing Carl Hubbell for fifth place in franchise history. He made several appearances in relief during the second half of the 2017 season and recorded his first career hold in August against the Milwaukee Brewers.