Skip to content

Commit 2e3f1f9

Browse files
authored
Merge branch 'develop' into automate-flake-updates
2 parents 4255624 + 550d9fd commit 2e3f1f9

22 files changed

Lines changed: 345 additions & 154 deletions

Dockerfile-orioledb-17

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,6 @@ RUN sed -i 's/ timescaledb,//g;' "/etc/postgresql/postgresql.conf" && \
157157
RUN sed -i 's/\(shared_preload_libraries.*\)'\''\(.*\)$/\1, orioledb'\''\2/' "/etc/postgresql/postgresql.conf" && \
158158
echo "default_table_access_method = 'orioledb'" >> "/etc/postgresql/postgresql.conf"
159159

160-
# OrioleDB rewind configuration
161-
# Enables time-based rewind capability for up to 20 minutes (1200 seconds)
162-
# Buffer size: 1280 buffers * 8KB = 10MB for transaction retention
163-
RUN echo "orioledb.enable_rewind = true" >> "/etc/postgresql/postgresql.conf" && \
164-
echo "orioledb.rewind_max_time = 1200" >> "/etc/postgresql/postgresql.conf" && \
165-
echo "orioledb.rewind_max_transactions = 100000" >> "/etc/postgresql/postgresql.conf" && \
166-
echo "orioledb.rewind_buffers = 1280" >> "/etc/postgresql/postgresql.conf"
167-
168160
# Include schema migrations
169161
COPY migrations/db /docker-entrypoint-initdb.d/
170162
COPY ansible/files/pgbouncer_config/pgbouncer_auth_schema.sql /docker-entrypoint-initdb.d/init-scripts/00-schema.sql

ansible/tasks/setup-system.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@
167167
state: 'present'
168168

169169
# postgres_exporter runs on port 9187 and postgresT occasionlly chooses it as random srcport
170-
- name: Set net.ipv4.ip_local_reserved_ports=9187
170+
# adminapi for 8085
171+
- name: Set net.ipv4.ip_local_reserved_ports
171172
ansible.builtin.sysctl:
172173
name: 'net.ipv4.ip_local_reserved_ports'
173-
value: 9187
174+
value: '9187,8085'
174175
state: 'present'
175176

176177
- name: Execute tasks when (debpkg_mode or nixpkg_mode)

ansible/tasks/stage2-setup-postgres.yml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,38 +52,6 @@
5252
path: '/etc/postgresql/postgresql.conf'
5353
state: 'present'
5454

55-
- name: Enable OrioleDB rewind feature
56-
ansible.builtin.lineinfile:
57-
path: /etc/postgresql/postgresql.conf
58-
line: "orioledb.enable_rewind = true"
59-
state: present
60-
when: is_psql_oriole and stage2_nix
61-
become: yes
62-
63-
- name: Set OrioleDB rewind max time (20 minutes)
64-
ansible.builtin.lineinfile:
65-
path: /etc/postgresql/postgresql.conf
66-
line: "orioledb.rewind_max_time = 1200"
67-
state: present
68-
when: is_psql_oriole and stage2_nix
69-
become: yes
70-
71-
- name: Set OrioleDB rewind max transactions
72-
ansible.builtin.lineinfile:
73-
path: /etc/postgresql/postgresql.conf
74-
line: "orioledb.rewind_max_transactions = 100000"
75-
state: present
76-
when: is_psql_oriole and stage2_nix
77-
become: yes
78-
79-
- name: Set OrioleDB rewind buffers (1280 buffers = 10MB)
80-
ansible.builtin.lineinfile:
81-
path: /etc/postgresql/postgresql.conf
82-
line: "orioledb.rewind_buffers = 1280"
83-
state: present
84-
when: is_psql_oriole and stage2_nix
85-
become: yes
86-
8755
- name: Add ORIOLEDB_ENABLED environment variable
8856
ansible.builtin.lineinfile:
8957
line: 'ORIOLEDB_ENABLED=true'

ansible/vars.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ postgres_major:
1010

1111
# Full version strings for each major version
1212
postgres_release:
13-
postgresorioledb-17: "17.6.0.041-orioledb"
14-
postgres17: "17.6.1.084"
15-
postgres15: "15.14.1.084"
13+
postgresorioledb-17: "17.6.0.044-orioledb"
14+
postgres17: "17.6.1.087"
15+
postgres15: "15.14.1.087"
1616

1717
# Non Postgres Extensions
1818
pgbouncer_release: 1.25.1

nix/config.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ in
5656
};
5757
orioledb = {
5858
"17" = {
59-
version = "17_15";
60-
hash = "sha256-1v3FGIN0UW+E4ilLwbsV3nXvef3n9O8bVmgyjRFEJsU=";
59+
version = "17_16";
60+
hash = "sha256-Xm9IUsvmlcayNQH8TCvHoIV23xkt/WQV0Oy4CiJkywc=";
6161
};
6262
};
6363
};

nix/devShells.nix

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,28 @@
3232
export HISTFILE=.history
3333
'';
3434
};
35+
docvenv = pkgs.python3.buildEnv.override {
36+
extraLibs = self'.packages.docs.nativeBuildInputs;
37+
};
3538
in
3639
{
3740
devShells = {
3841
default = pkgs.devshell.mkShell {
39-
packages =
40-
with pkgs;
41-
[
42-
coreutils
43-
just
44-
nix-update
45-
#pg_prove
46-
shellcheck
47-
ansible
48-
ansible-lint
49-
aws-vault
50-
packer
51-
dbmate
52-
nushell
53-
pythonEnv
54-
config.treefmt.build.wrapper
55-
]
56-
++ self'.packages.docs.nativeBuildInputs;
42+
packages = with pkgs; [
43+
coreutils
44+
just
45+
nix-update
46+
#pg_prove
47+
shellcheck
48+
ansible
49+
ansible-lint
50+
aws-vault
51+
packer
52+
dbmate
53+
nushell
54+
pythonEnv
55+
config.treefmt.build.wrapper
56+
];
5757
devshell.startup.pre-commit.text = config.pre-commit.installationScript;
5858
commands = [
5959
{
@@ -74,6 +74,12 @@
7474
command = "pre-commit run --all-files";
7575
category = "check";
7676
}
77+
{
78+
name = "serve-nix-doc";
79+
help = "Spin up a server exposing the nix documentation";
80+
command = "pushd $(git rev-parse --show-toplevel)/nix && ${docvenv}/bin/mkdocs serve -o";
81+
category = "doc";
82+
}
7783
{
7884
name = "watch";
7985
help = "Watch for file changes and run all checks";

nix/docs/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,19 @@ learn how to play with `postgres` in the [build guide](./build-postgres.md).
1818
- **[Receipt Files](./receipt-files.md)** - Understanding build receipts
1919
- **[Start Client/Server](./start-client-server.md)** - Running PostgreSQL client and server
2020
- **[Docker](./docker.md)** - Docker integration and usage
21+
- **[Docker Image Size Analyzer](./image-size-analyzer-usage.md)** - Tool to analyze the Docker image sizes
2122
- **[Use direnv](./use-direnv.md)** - Development environment with direnv
2223
- **[Pre-commit Hooks](./pre-commit-hooks.md)** - Automatic formatting and code checks before commits
2324
- **[Nix Formatter](./nix-formatter.md)** - Code formatting with treefmt
25+
- **[Create a New pgrx Extension](./creating-pgrx-extension.md)** - How to set up a new cargo pgrx extension
26+
- **[Updating pgrx Extensions](./updating-pgrx-extensions.md)** - How to upgrade the cargo pgrx extensions
27+
- **[Receipt Files](./receipt-files.md)** - Understand what receipt files are
2428

2529
## Package Management
2630

2731
- **[Adding New Packages](./adding-new-package.md)** - How to add new PostgreSQL extensions
2832
- **[Update Extensions](./update-extension.md)** - How to update existing extensions
33+
- **[Update Nix Dependecies](./updating-dependencies.md)** - How to update the Nix dependencies
2934
- **[New Major PostgreSQL](./new-major-postgres.md)** - Adding support for new PostgreSQL versions
3035
- **[Nix Overlays](./nix-overlays.md)** - Understanding and using Nix overlays
3136

@@ -34,6 +39,7 @@ learn how to play with `postgres` in the [build guide](./build-postgres.md).
3439
- **[Adding Tests](./adding-tests.md)** - How to add tests for extensions
3540
- **[Migration Tests](./migration-tests.md)** - Testing database migrations
3641
- **[Testing PG Upgrade Scripts](./testing-pg-upgrade-scripts.md)** - Testing PostgreSQL upgrades
42+
- **[Docker Image testing](./docker-testing.md)** - How to test the docker images against the pg_regress test suite.
3743

3844
## Reference
3945

nix/docs/adding-tests.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ There are basically two types of tests you can add:
55
- Migration tests.
66

77
In all cases, a number of extensions may be installed into the database for
8-
use; you can see those in both [postgresql.conf.in](../tests/postgresql.conf.in)
9-
and [prime.sql](../tests/prime.sql) (extensions may be enabled in either place.)
8+
use; you can see those in both `/nix/tests/postgresql.conf.in`
9+
and `/nix/tests/prime.sql` (extensions may be enabled in either place.)
1010

1111
## pg\_regress tests
1212

13-
pg\_regress tests are in [tests/sql](./../tests/sql/) with output in [tests/expected](./../tests/expected/).
14-
To create a new test, create a new SQL file in [tests/sql](./../tests/sql/)
13+
pg\_regress tests are in `/nix/tests/sql/` with output in `/nix/tests/expected/`.
14+
To create a new test, create a new SQL file in `/nix/tests/sql/`.
1515

1616
Next, for each current major version of postgres, we run a "flake check" build one at a time.
1717

@@ -29,8 +29,8 @@ Next, review the logs to identify where the test output was written
2929

3030
```
3131
postgres> CREATE EXTENSION IF NOT EXISTS index_advisor;
32-
postgres> CREATE EXTENSION
33-
postgres> (using postmaster on localhost, port 5432)
32+
postgres> CREATE EXTENSION
33+
postgres> (using postmaster on localhost, port 5432)
3434
postgres> ============== running regression test queries ==============
3535
postgres> test new_test ... diff: /nix/store/5gk419ddz7mzzwhc9j6yj5i8lkw67pdl-tests/expected/new_test.out: No such file or directory
3636
postgres> diff command failed with status 512: diff "/nix/store/5gk419ddz7mzzwhc9j6yj5i8lkw67pdl-tests/expected/new_test.out" "/nix/store/2fbrvnnr7iz6yigyf0rb0vxnyqvrgxzp-postgres-15.6-check-harness/regression_output/results/new_test.out" > "/nix/store/2fbrvnnr7iz6yigyf0rb0vxnyqvrgxzp-postgres-15.6-check-harness/regression_output/results/new_test.out.diff
@@ -44,15 +44,15 @@ cp -r /nix/store/2fbrvnnr7iz6yigyf0rb0vxnyqvrgxzp-postgres-15.6-check-harness/re
4444

4545
Then you can review the contents of `regression_output/results/new_test.out` to see if it matches what you expected.
4646

47-
If it does match your expectations, copy the file to [tests/expected](./../tests/expected/) and the test will pass on the next run.
47+
If it does match your expectations, copy the file to `/nix/tests/expected/` and the test will pass on the next run.
4848

4949
If the output does not match your expectations, update the `<new_test>.sql` file, re-run with `nix flake check -L` and try again
5050

5151

5252
## pgTAP tests
5353

5454
These are super easy: simply add `.sql` files to the
55-
[tests/smoke](./../tests/smoke/) directory, then:
55+
`/nix/tests/smoke/` directory, then:
5656

5757
```
5858
nix flake check -L
@@ -100,7 +100,7 @@ extension authors), step 3 isn't guaranteed, so that's what the whole idea is
100100
designed to test.
101101

102102
To add data into the database, modify the
103-
[data.sql](../nix/tests/migrations/data.sql) script and add whatever you want into
103+
`/nix/tests/migrations/data.sql` script and add whatever you want into
104104
it. This script gets loaded into the old version of the database at startup, and
105105
it's expected that the new version of the database can handle it.
106106

nix/docs/development-workflow.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ nix run .#trigger-nix-build
2020
```
2121

2222
This will:
23+
2324
- Trigger a GitHub Actions workflow
2425
- Build PostgreSQL and extensions
2526
- Run nix flake check tests (evaluation of nix code, pg_regress and migrations tests)
2627
- Cache the results in the Supabase Nix binary cache
2728
- Watch the workflow progress until completion
2829

29-
The workflow will run on the branch you're currently on.
30+
The workflow will run on the branch you're currently on.
3031

3132
If you're on a feature different branch, you'll be prompted to confirm before proceeding.
3233

@@ -46,6 +47,7 @@ aws-vault exec <profile-name> -- nix run .#build-test-ami orioledb-17
4647
```
4748

4849
This will:
50+
4951
- Build two AMI stages using Packer
5052
- Clean up temporary instances after AMI builds
5153
- Output the final AMI name (e.g., `supabase-postgres-abc123`)
@@ -62,13 +64,15 @@ nix run .#run-testinfra -- --aws-vault-profile <profile-name> --ami-name supabas
6264
```
6365

6466
This will:
67+
6568
- Create a Python virtual environment
6669
- Install required Python packages
6770
- Create an EC2 instance from the AMI
6871
- Run the test suite
6972
- Automatically terminate the EC2 instance when done
7073

7174
The script handles:
75+
7276
- Setting up AWS credentials via aws-vault
7377
- Creating and managing the Python virtual environment
7478
- Running the tests
@@ -85,6 +89,7 @@ aws-vault exec <profile-name> -- nix run .#cleanup-ami supabase-postgres-abc123
8589
```
8690

8791
This will:
92+
8893
- Deregister the AMI
8994
- Clean up any associated resources
9095

@@ -109,26 +114,29 @@ This will:
109114
### Environment Variables
110115

111116
The following environment variables are used:
117+
112118
- `AWS_VAULT`: AWS Vault profile name (default: staging)
113119
- `AWS_REGION`: AWS region (default: ap-southeast-1)
114120
- `AMI_NAME`: Name of the AMI to test
115121

116122
## Best Practices
117123

118124
1. **Branch Management**
119-
- Use feature branches for development
120-
- Merge to develop for testing
121-
- Use release branches for version-specific changes
125+
126+
- Use feature branches for development
127+
- Merge to develop for testing
128+
- Use release branches for version-specific changes
122129

123130
2. **Resource Cleanup**
124-
- Always run the cleanup step after testing
125-
- Monitor AWS console for any lingering resources
126-
- Use the cleanup-ami command when done with an AMI
131+
132+
- Always run the cleanup step after testing
133+
- Monitor AWS console for any lingering resources
134+
- Use the cleanup-ami command when done with an AMI
127135

128136
3. **Testing**
129-
- Run tests locally before pushing changes
130-
- Verify AMI builds before running testinfra
131-
- Check test output for any warnings or errors
137+
- Run tests locally before pushing changes
138+
- Verify AMI builds before running testinfra
139+
- Check test output for any warnings or errors
132140

133141
## Additional Commands
134142

@@ -138,4 +146,4 @@ nix run .#show-commands
138146

139147
# Update README with latest command information
140148
nix run .#update-readme
141-
```
149+
```

nix/docs/documentation.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ We are using markdown for documentation in the `nix/docs` directory, which is re
77
To generate the documentation locally, you can use the following command in a development shell:
88

99
```bash
10-
cd nix
11-
mkdocs serve
10+
serve-nix-doc
1211
```
1312

1413
This will start a local server at `http://localhost:8000` where you can view the documentation.

0 commit comments

Comments
 (0)