You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
auto success = ReadInternal(handle, buffer, nr_bytes, location);
474
+
if (success) {
475
+
return;
476
+
}
477
+
478
+
// ReadInternal returned false. This means the regular path of querying the file with range requests failed. We will
479
+
// attempt to download the full file and retry.
480
+
481
+
if (handle.logger) {
482
+
DUCKDB_LOG_WARN(handle.logger, "Falling back to full file download for file '%s': the server does not support HTTP range requests. Performance and memory usage are potentially degraded.", handle.path);
483
+
}
484
+
485
+
auto &hfh = handle.Cast<HTTPFileHandle>();
486
+
487
+
bool should_write_cache = false;
488
+
hfh.FullDownload(*this, should_write_cache);
489
+
490
+
if (!ReadInternal(handle, buffer, nr_bytes, location)) {
491
+
throwHTTPException("Failed to read from HTTP file after automatically retrying a full file download.");
config.AddExtensionOption("http_retries", "HTTP retries on I/O error", LogicalType::UBIGINT, Value(3));
48
48
config.AddExtensionOption("http_retry_wait_ms", "Time between retries", LogicalType::UBIGINT, Value(100));
49
49
config.AddExtensionOption("force_download", "Forces upfront download of file", LogicalType::BOOLEAN, Value(false));
50
+
config.AddExtensionOption("auto_fallback_to_full_download", "Allows automatically falling back to full file downloads when possible.", LogicalType::BOOLEAN, Value(true));
50
51
// Reduces the number of requests made while waiting, for example retry_wait_ms of 50 and backoff factor of 2 will
51
52
// result in wait times of 0 50 100 200 400...etc.
52
53
config.AddExtensionOption("http_retry_backoff", "Backoff factor for exponentially increasing retry wait time",
staticconstexpr ExceptionType TYPE = ExceptionType::HTTP;
23
+
staticconstexprconstchar *MESSAGE = "Content-Length from server mismatches requested range, server may not support range requests. You can try to resolve this by enabling `SET force_download=true`";
24
+
25
+
staticvoidThrow() {
26
+
throwHTTPException(MESSAGE);
27
+
}
28
+
};
29
+
17
30
classHTTPClientCache {
18
31
public:
19
32
//! Get a client from the client cache
@@ -50,6 +63,8 @@ class HTTPFileHandle : public FileHandle {
50
63
string etag;
51
64
bool force_full_download;
52
65
bool initialized = false;
66
+
67
+
bool auto_fallback_to_full_file_download = true;
53
68
54
69
// In write overwrite mode, we are not interested in the current state of the file: we're overwriting it.
55
70
bool write_overwrite_mode = false;
@@ -88,7 +103,10 @@ class HTTPFileHandle : public FileHandle {
88
103
//! Perform a HEAD request to get the file info (if not yet loaded)
copy lineitem to '${PYTHON_HTTP_SERVER_DIR}/lineitem.csv'
22
+
23
+
statement ok
24
+
drop table lineitem;
25
+
26
+
statement ok
27
+
CREATE view lineitem AS FROM '${PYTHON_HTTP_SERVER_URL}/lineitem.csv';
28
+
29
+
query I
30
+
pragma tpch(6);
31
+
----
32
+
123141078.22829981
33
+
34
+
query I
35
+
select count(*) from duckdb_logs where log_level='WARN' and message like '%Falling back to full%'
36
+
----
37
+
2
38
+
39
+
statement ok
40
+
set auto_fallback_to_full_download=false
41
+
42
+
statement error
43
+
pragma tpch(6);
44
+
----
45
+
HTTP Error: Content-Length from server mismatches requested range, server may not support range requests. You can try to resolve this by enabling `SET force_download=true`
0 commit comments