Skip to content

Commit efe044c

Browse files
committed
vendor: Update vendored sources to duckdb/duckdb@fb5dba5
Fix issue with `ExternalFileCache` when data is evicted (duckdb/duckdb#17567)
1 parent 4b2f5ac commit efe044c

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

src/duckdb/extension/parquet/include/thrift_tools.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ struct ReadAheadBuffer {
119119
throw std::runtime_error("Prefetch registered requested for bytes outside file");
120120
}
121121
read_head.buffer_handle = file_handle.Read(read_head.buffer_ptr, read_head.size, read_head.location);
122+
D_ASSERT(read_head.buffer_handle.IsValid());
122123
read_head.data_isset = true;
123124
}
124125
}
@@ -141,8 +142,10 @@ class ThriftFileTransport : public duckdb_apache::thrift::transport::TVirtualTra
141142
if (!prefetch_buffer->data_isset) {
142143
prefetch_buffer->buffer_handle =
143144
file_handle.Read(prefetch_buffer->buffer_ptr, prefetch_buffer->size, prefetch_buffer->location);
145+
D_ASSERT(prefetch_buffer->buffer_handle.IsValid());
144146
prefetch_buffer->data_isset = true;
145147
}
148+
D_ASSERT(prefetch_buffer->buffer_handle.IsValid());
146149
memcpy(buf, prefetch_buffer->buffer_ptr + location - prefetch_buffer->location, len);
147150
} else if (prefetch_mode && len < PREFETCH_FALLBACK_BUFFERSIZE && len > 0) {
148151
Prefetch(location, MinValue<uint64_t>(PREFETCH_FALLBACK_BUFFERSIZE, file_handle.GetFileSize() - location));

src/duckdb/src/function/table/version/pragma_version.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef DUCKDB_PATCH_VERSION
2-
#define DUCKDB_PATCH_VERSION "0-dev3669"
2+
#define DUCKDB_PATCH_VERSION "0-dev3672"
33
#endif
44
#ifndef DUCKDB_MINOR_VERSION
55
#define DUCKDB_MINOR_VERSION 3
@@ -8,10 +8,10 @@
88
#define DUCKDB_MAJOR_VERSION 1
99
#endif
1010
#ifndef DUCKDB_VERSION
11-
#define DUCKDB_VERSION "v1.3.0-dev3669"
11+
#define DUCKDB_VERSION "v1.3.0-dev3672"
1212
#endif
1313
#ifndef DUCKDB_SOURCE_ID
14-
#define DUCKDB_SOURCE_ID "4e57d13663"
14+
#define DUCKDB_SOURCE_ID "fb5dba52ab"
1515
#endif
1616
#include "duckdb/function/table/system_functions.hpp"
1717
#include "duckdb/main/database.hpp"

src/duckdb/src/storage/caching_file_system.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ BufferHandle CachingFileHandle::TryReadFromCache(data_ptr_t &buffer, idx_t nr_by
236236
if (it != ranges.begin()) {
237237
--it;
238238
}
239-
for (it = ranges.begin(); it != ranges.end();) {
239+
while (it != ranges.end()) {
240240
if (it->second->location >= this_end) {
241241
// We're past the requested location
242242
break;
@@ -285,12 +285,16 @@ BufferHandle CachingFileHandle::TryInsertFileRange(BufferHandle &pin, data_ptr_t
285285
auto &ranges = cached_file.Ranges(guard);
286286

287287
// Start at lower_bound (first range with location not less than location of newly created range)
288-
for (auto it = ranges.lower_bound(location); it != ranges.end();) {
288+
auto it = ranges.lower_bound(location);
289+
if (it != ranges.begin()) {
290+
--it;
291+
}
292+
while (it != ranges.end()) {
289293
if (it->second->GetOverlap(*new_file_range) == CachedFileRangeOverlap::FULL) {
290294
// Another thread has read a range that fully contains the requested range in the meantime
291-
pin = TryReadFromFileRange(guard, *it->second, buffer, nr_bytes, location);
292-
if (pin.IsValid()) {
293-
return std::move(pin);
295+
auto other_pin = TryReadFromFileRange(guard, *it->second, buffer, nr_bytes, location);
296+
if (other_pin.IsValid()) {
297+
return other_pin;
294298
}
295299
it = ranges.erase(it);
296300
continue;
@@ -314,8 +318,10 @@ BufferHandle CachingFileHandle::TryInsertFileRange(BufferHandle &pin, data_ptr_t
314318
if (break_loop) {
315319
break;
316320
}
321+
317322
++it;
318323
}
324+
D_ASSERT(pin.IsValid());
319325

320326
// Finally, insert newly created buffer into the map
321327
new_file_range->AddCheckSum();

src/duckdb/src/storage/external_file_cache.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ void ExternalFileCache::CachedFileRange::VerifyCheckSum() {
5050
return;
5151
}
5252
auto buffer_handle = block_handle->block_manager.buffer_manager.Pin(block_handle);
53+
if (!buffer_handle.IsValid()) {
54+
return;
55+
}
5356
D_ASSERT(checksum == Checksum(buffer_handle.Ptr(), nr_bytes));
5457
#endif
5558
}
@@ -61,7 +64,7 @@ void ExternalFileCache::CachedFile::Verify(const unique_ptr<StorageLockKey> &gua
6164
#ifdef DEBUG
6265
for (const auto &range1 : ranges) {
6366
for (const auto &range2 : ranges) {
64-
if (range1 == range2) {
67+
if (range1.first == range2.first) {
6568
continue;
6669
}
6770
D_ASSERT(range1.second->GetOverlap(*range2.second) != CachedFileRangeOverlap::FULL);

0 commit comments

Comments
 (0)