There is a bug in GalleryDataCache::putPageData() that causes a database error when two requests for the same page are sent within one second. (Double click on the "next-image" Button or on the browser reload button.)
The problem is that $storage->getAffectedRows() after updateMapEntry only returns 1 if any data has actually been changed!
This seems to be a known problem in mysqli:
If the second UPDATE comes within the same second, the values to update are identically to the values that have already been written by the first request. So $storage->getAffectedRows() thinks that the UPDATE didn't match any row and tries an INSERT. This, of course fails, another UPDATE is done, which yields affectedRows=0 again. And the second INSERT causes the ERROR_STORAGE_FAILURE.
This error applys at least to systems using the mysql or mysqli database driver.
Unfortunately there is no database independent way of getting the number of rows matched (as opposed to the number of rows changed) by the the UPDATE in GalleryCoreApi::updateMapEntry().
The attached suboptimal patch fixes the problem for now.