Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not reindex concurrently on PG < v16 #71

Merged
merged 2 commits into from
Dec 10, 2024
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ $ docker run --name pgauto -it \
<NAME_OF_THE_PGAUTOUPGRADE_IMAGE>
```

### Skip reindexing
### Reindexing

By default, all databases are reindexed after the migration, which can take some time if they are large.
To skip reindexing, set the environment variable `PGAUTO_REINDEX` to `no`, for example:
Expand All @@ -89,6 +89,9 @@ $ docker run --name pgauto -it \
<NAME_OF_THE_PGAUTOUPGRADE_IMAGE>
```

> [!WARNING]
> PG v15 and below do not support reindexing system tables in a database concurrently. This means, when we run start the indexing operation, database locks are placed which do not allow for any modifications as long as the task is running. We recommend using PG v16 or v17 where this is not an issue.

# For Developers

## Building the image
Expand Down
19 changes: 6 additions & 13 deletions pgautoupgrade-postupgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,12 @@ if [ "x${PGAUTO_REINDEX}" != "xno" ]; then
echo "------------------------"
echo "Reindexing the databases"
echo "------------------------"

# For each database, reindex it
for DATABASE in ${DB_LIST}; do
echo "-------------------------------"
echo "Starting reindex of ${DATABASE}"
echo "-------------------------------"

echo 'REINDEX DATABASE CONCURRENTLY' | psql --username="${POSTGRES_USER}" -t --csv "${DATABASE}"

echo "-------------------------------"
echo "Finished reindex of ${DATABASE}"
echo "-------------------------------"
done

if [[ "$PGTARGET" -le 15 ]]; then
reindexdb --all --username="${POSTGRES_USER}"
else
reindexdb --all --concurrently --username="${POSTGRES_USER}"
fi

echo "-------------------------------"
echo "End of reindexing the databases"
Expand Down
Loading