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

*: add support for PostgreSQL 13 #831

Merged
merged 1 commit into from
Mar 19, 2021
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
10 changes: 5 additions & 5 deletions .agola/config.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ local task_build_push_images(name, pgversions, istag, push) =
task_integration_tests(store, pgversion, 'amd64'),
]
for store in ['etcdv2', 'consul']
for pgversion in ['12']
for pgversion in ['13']
]) + std.flattenArrays([
[
task_integration_tests(store, pgversion, 'amd64'),
]
for store in ['etcdv3']
for pgversion in ['9.5', '9.6', '10', '11', '12']
for pgversion in [ '9.6', '10', '11', '12', '13']
]) + [
task_build_push_images('test build docker "stolon" images', '9.4 9.5 9.6 10 11 12', false, false)
task_build_push_images('test build docker "stolon" images', '9.6 10 11 12 13', false, false)
+ {
when: {
branch: {
Expand All @@ -190,13 +190,13 @@ local task_build_push_images(name, pgversions, istag, push) =
ref: '#refs/pull/\\d+/head#',
},
},
task_build_push_images('build and push docker "stolon" master branch images', '9.4 9.5 9.6 10 11 12', false, true)
task_build_push_images('build and push docker "stolon" master branch images', '9.6 10 11 12 13', false, true)
+ {
when: {
branch: 'master',
},
},
task_build_push_images('build and push docker "stolon" tag images', '9.4 9.5 9.6 10 11 12', true, true)
task_build_push_images('build and push docker "stolon" tag images', '9.6 10 11 12 13', true, true)
+ {
when: {
tag: '#v.*#',
Expand Down
34 changes: 32 additions & 2 deletions cmd/keeper/cmd/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func init() {
var managedPGParameters = []string{
"unix_socket_directories",
"wal_keep_segments",
"wal_keep_size",
"hot_standby",
"listen_addresses",
"port",
Expand Down Expand Up @@ -250,13 +251,42 @@ func (p *PostgresKeeper) walKeepSegments(db *cluster.DB) int {
return walKeepSegments
}

func (p *PostgresKeeper) walKeepSize(db *cluster.DB) string {
// assume default 16Mib wal segment size
walKeepSize := strconv.Itoa(minWalKeepSegments * 16)

// TODO(sgotti) currently we ignore if wal_keep_size value is less than our
// min value or wrong and just return it as is
if db.Spec.PGParameters != nil {
if v, ok := db.Spec.PGParameters["wal_keep_size"]; ok {
return v
}
}

return walKeepSize
}

func (p *PostgresKeeper) mandatoryPGParameters(db *cluster.DB) common.Parameters {
return common.Parameters{
params := common.Parameters{
"unix_socket_directories": common.PgUnixSocketDirectories,
"wal_level": p.walLevel(db),
"wal_keep_segments": fmt.Sprintf("%d", p.walKeepSegments(db)),
"hot_standby": "on",
}

maj, _, err := p.pgm.BinaryVersion()
if err != nil {
// in case we fail to parse the binary version don't return any wal_keep_segments or wal_keep_size
log.Warnf("failed to get postgres binary version: %v", err)
return params
}

if maj >= 13 {
params["wal_keep_size"] = p.walKeepSize(db)
} else {
params["wal_keep_segments"] = fmt.Sprintf("%d", p.walKeepSegments(db))
}

return params
}

func (p *PostgresKeeper) getSUConnParams(db, followedDB *cluster.DB) pg.ConnParams {
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ func TestWalKeepSegments(t *testing.T) {
t.Fatalf("unexpected err: %v", err)
}

maj, _, err := tk.PGDataVersion()
if err != nil {
t.Fatalf("unexpected err: %v", err)
}
if maj >= 13 {
t.Skipf("skipping since postgres version %d >= 13", maj)
}

// "archive" isn't an accepted wal_level
err = StolonCtl(t, clusterName, tstore.storeBackend, storeEndpoints, "update", "--patch", `{ "pgParameters" : { "wal_level": "archive" } }`)
if err != nil {
Expand Down