One thing I didn’t realize was being shown in Rey’s vision was Kylo and his men killing Jedi. Those were probably all the ones Luke had trained since ROTJ, and they’ve been wiped out. Luke putting his hand on Artoo was probably after he discovers this. He doesn’t just feel the pain of failing with Ren, he’s lost an entire generation of new Jedi. That’s a terrible burden to bear.
The fact that it was a flashback passed me by for some reason. I thought it was a vision of the future, but realized by the end of the movie that that didn’t make a lot of sense.