- Shipped
- August 16, 2026 at 1:13 AM UTC
- Author
- Kamo
- Commit
- 3cc8b30
Spring Data derives a second statement for every Page it returns, and the chat history read asked for one it never looked at: MediaController takes page.getContent() and then reports messages.size() as the count. The derived statement was SELECT COUNT(m1_0.id) FROM media_objs m1_0 LEFT JOIN media_objs_msg m3_0 ON m1_0.id = m3_0.obj_id WHERE m1_0.session_id = ? AND m1_0.is_removed = false — an unindexed aggregate over every object in the session, issued after the transaction had already read, which is precisely the shape YugabyteDB cannot recover from. It can only transparently restart a read that is the FIRST statement in its transaction; a later one raises SQLState 40001 "Restart read required", the transaction is marked rollback-only, and the request 500s. So an open chat window that happened to reload while somebody was writing to the same session showed no history at all, on account of a number that was discarded. The rows now come back as a List, which issues no count. Same query, same order, same page; one statement instead of two. The Page-returning method stays for MediaStreamController, which genuinely serves **************** to the social feed. Every other caller was taking .getContent() and throwing the total away, so the two public-chat sites move across too (MediaService, separate commit).