Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/IntegrationTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ jobs:
needs: linux-tests
runs-on: ubuntu-latest

strategy:
matrix:
threadsan: [0, 1]

env:
CMAKE_BUILD_PARALLEL_LEVEL: 2
CC: 'ccache gcc'
Expand Down Expand Up @@ -286,7 +290,7 @@ jobs:
working-directory: ./duckdb
run: |
DUCKDB_VERSION=$(git rev-parse --short HEAD)
KEY="${{ runner.os }}-${{ runner.arch }}-$DUCKDB_VERSION"-relassert
KEY="${{ runner.os }}-${{ runner.arch }}-$DUCKDB_VERSION"-relassert-${{ matrix.threadsan }}
echo "value=${KEY}" >> "${GITHUB_OUTPUT}"

- name: Restore Cache
Expand All @@ -311,8 +315,11 @@ jobs:
vcpkgGitCommitId: 84bab45d415d22042bd0b9081aea57f362da3f35

- name: Build extension
env:
THREADSAN: ${{ matrix.threadsan }}
run: |
make relassert
cat ./build/relassert/src/CMakeFiles/duckdb.dir/flags.make
cd build
ln -s relassert release

Expand Down
2 changes: 1 addition & 1 deletion src/include/storage/postgres_table_entry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class PostgresTableEntry : public TableCatalogEntry {
//! We would in this case remap them to "ID" and "id:1", while postgres_names store the original names
vector<string> postgres_names;
//! The approximate number of pages a table consumes in Postgres
int64_t approx_num_pages;
std::atomic<int64_t> approx_num_pages;
};

} // namespace duckdb
1 change: 1 addition & 0 deletions src/postgres_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ static unique_ptr<LocalTableFunctionState> GetLocalState(ClientContext &context,
}
if (bind_data.pages_approx == 0 || bind_data.requires_materialization) {
PostgresInitInternal(context, &bind_data, *local_state, 0, POSTGRES_TID_MAX);
lock_guard<mutex> parallel_lock(gstate.lock);
gstate.page_idx = POSTGRES_TID_MAX;
} else if (!PostgresParallelStateNext(context, input.bind_data.get(), *local_state, gstate)) {
local_state->done = true;
Expand Down
2 changes: 1 addition & 1 deletion src/storage/postgres_insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ SinkFinalizeType PostgresInsert::Finalize(Pipeline &pipeline, Event &event, Clie
idx_t bytes_per_page = 8192;
idx_t bytes_per_row = gstate.table.GetColumns().LogicalColumnCount() * 8;
idx_t rows_per_page = MaxValue<idx_t>(1, bytes_per_page / bytes_per_row);
gstate.table.approx_num_pages += gstate.insert_count / rows_per_page;
gstate.table.approx_num_pages.fetch_add(gstate.insert_count / rows_per_page, std::memory_order_acq_rel);
return SinkFinalizeType::READY;
}

Expand Down
7 changes: 4 additions & 3 deletions src/storage/postgres_table_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ PostgresTableEntry::PostgresTableEntry(Catalog &catalog, SchemaCatalogEntry &sch
postgres_types.push_back(PostgresUtils::CreateEmptyPostgresType(col.GetType()));
postgres_names.push_back(col.GetName());
}
approx_num_pages = 0;
approx_num_pages.store(0, std::memory_order_release);
}

PostgresTableEntry::PostgresTableEntry(Catalog &catalog, SchemaCatalogEntry &schema, PostgresTableInfo &info)
: TableCatalogEntry(catalog, schema, *info.create_info), postgres_types(std::move(info.postgres_types)),
postgres_names(std::move(info.postgres_names)) {
D_ASSERT(postgres_types.size() == columns.LogicalColumnCount());
approx_num_pages = info.approx_num_pages;
approx_num_pages.store(info.approx_num_pages, std::memory_order_release);
}

unique_ptr<BaseStatistics> PostgresTableEntry::GetStatistics(ClientContext &context, column_t column_id) {
Expand Down Expand Up @@ -54,7 +54,8 @@ TableFunction PostgresTableEntry::GetScanFunction(ClientContext &context, unique
result->names = postgres_names;
result->postgres_types = postgres_types;
result->read_only = transaction.IsReadOnly();
PostgresScanFunction::PrepareBind(pg_catalog.GetPostgresVersion(), context, *result, approx_num_pages);
PostgresScanFunction::PrepareBind(pg_catalog.GetPostgresVersion(), context, *result,
approx_num_pages.load(std::memory_order_acquire));

bind_data = std::move(result);
auto function = PostgresScanFunction();
Expand Down
Loading