Issue #3414287 by catch, longwave: Avoid reading session from the database multiple times during a big pipe request (cherry picked from commit 213906e2)