Skip to content

Commit c2a59cb

Browse files
committed
Log HTTPException from OpenFile and Write in caching filesystem
Wrap the remote OpenFile call and both Write overloads with a try block that emits a PGDUCK_SERVER_WARN for ExceptionType::HTTP and rethrows. DuckDB's HTTPException message already carries URL, status code, and reason, so a 404, 403, or 500 on an S3 object now surfaces a single WARNING line before the error propagates to the client. Non-HTTP exceptions pass through silently. Signed-off-by: Marco Slot <marco.slot@snowflake.com>
1 parent 860d3d6 commit c2a59cb

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

duckdb_pglake/src/fs/caching_file_system.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,17 @@ PGLakeCachingFileSystem::OpenFile(const string &fullUrl,
120120
else
121121
{
122122
/* create a handle for the remote file */
123-
wrappedHandle = remoteFs->OpenFile(url, openFlags, opener);
123+
try
124+
{
125+
wrappedHandle = remoteFs->OpenFile(url, openFlags, opener);
126+
}
127+
catch (Exception &ex)
128+
{
129+
ErrorData error(ex);
130+
if (error.Type() == ExceptionType::HTTP)
131+
PGDUCK_SERVER_WARN("%.500s", error.Message().c_str());
132+
throw;
133+
}
124134

125135
if (requestCache)
126136
{

duckdb_pglake/src/include/pg_lake/fs/caching_file_system.hpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,17 @@ class PGLakeCachingFileSystem : public FileSystem {
172172
if (pg_lakeHandle.context->interrupted)
173173
throw InterruptException();
174174

175-
wrappedHandle.file_system.Write(wrappedHandle, buffer, byteCount, location);
175+
try
176+
{
177+
wrappedHandle.file_system.Write(wrappedHandle, buffer, byteCount, location);
178+
}
179+
catch (Exception &ex)
180+
{
181+
ErrorData error(ex);
182+
if (error.Type() == ExceptionType::HTTP)
183+
PGDUCK_SERVER_WARN("%.500s", error.Message().c_str());
184+
throw;
185+
}
176186
}
177187

178188
int64_t Write(FileHandle &handle, void *buffer, int64_t byteCount) override {
@@ -220,7 +230,17 @@ class PGLakeCachingFileSystem : public FileSystem {
220230
CleanUpCacheOnWriteFile(pg_lakeHandle);
221231
}
222232

223-
return pg_lakeHandle.wrappedHandle->Write(buffer, byteCount);
233+
try
234+
{
235+
return pg_lakeHandle.wrappedHandle->Write(buffer, byteCount);
236+
}
237+
catch (Exception &ex)
238+
{
239+
ErrorData error(ex);
240+
if (error.Type() == ExceptionType::HTTP)
241+
PGDUCK_SERVER_WARN("%.500s", error.Message().c_str());
242+
throw;
243+
}
224244
}
225245

226246
bool CanHandleFile(const string &fpath) override {

0 commit comments

Comments
 (0)