Handle unexpected EOF while doing an LFC read more gracefully

There's a bug somewhere because this happens in python regression
tests. We need to hunt that down, but in any case, let's not get stuck
in an infinite loop if it happens.
This commit is contained in:
Heikki Linnakangas
2025-06-30 00:59:53 +03:00
parent 39f31957e3
commit 97a8f4ef85

View File

@@ -662,6 +662,19 @@ retry:
(errcode_for_file_access(),
errmsg("could not read block %lu in local cache file: %m",
cached_block)));
if (nbytes == 0)
{
/*
* FIXME: if the file was concurrently truncated, I guess
* this is expected. We should finish the read by calling
* bcomm_finish_cache_read(), and only throw the error if
* it reported success.
*/
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not read block %lu in local cache file (unexpected EOF)",
cached_block)));
}
bytes_total += nbytes;
}
}