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

database creation stuck in configuration phase #504

Closed
hFti opened this issue Oct 28, 2024 · 6 comments
Closed

database creation stuck in configuration phase #504

hFti opened this issue Oct 28, 2024 · 6 comments

Comments

@hFti
Copy link

hFti commented Oct 28, 2024

Affected modules

terraform-ibm-modules/icd-postgresql/ibm
version 3.17.9

Terraform CLI and Terraform provider versions

  • Terraform version: 1.5.7
  • Provider version: 1.68.1

Terraform output

timeout2

Expected behavior

databse created with conf in place

Actual behavior

configuration is stuck , terraform timed out and the database in console is always at 60%
stuck_3

Steps to reproduce (including links and screen captures)

use module with configuration variable set to the map below
`module "postgresql_db" {
source = "terraform-ibm-modules/icd-postgresql/ibm"
version = "3.17.9"
resource_group_id = ibm_resource_group.resource_group.id
name = "${var.env}-database-postgres"
region = var.region
pg_version = var.pg_version
admin_pass = var.admin_pass
users = var.users
kms_encryption_enabled = true
kms_key_crn = module.key_protect_all_inclusive.keys["icd-key"].crn
existing_kms_instance_guid = module.key_protect_all_inclusive.kms_guid
resource_tags = var.resource_tags
service_credential_names = var.service_credential_names
access_tags = var.access_tags
member_host_flavor = "b3c.4x16.encrypted"
auto_scaling = var.auto_scaling

configuration = {
shared_buffers = 32000
max_connections = 250
max_locks_per_transaction = 64
max_prepared_transactions = 0
synchronous_commit = "local"
effective_io_concurrency = 12
deadlock_timeout = 10000
log_connections = "off"
log_disconnections = "off"
log_min_duration_statement = 100
tcp_keepalives_idle = 200
tcp_keepalives_interval = 50
tcp_keepalives_count = 6
archive_timeout = 1000
wal_level = "hot_standby"
max_replication_slots = 10
max_wal_senders = 20
}
cbr_rules = [
{
description = "${var.env}-postgres access only from vpc"
enforcement_mode = "enabled"
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
rule_contexts = [{
attributes = [
{
"name" : "endpointType",
"value" : "private"
},
{
name = "networkZoneId"
value = module.cbr_zone.zone_id
}]
}]
}
]
}`
run terraform apply

Anything else

@hFti
Copy link
Author

hFti commented Oct 30, 2024

@lionelmace

@ocofaigh
Copy link
Member

@hFti I suggest you create a support case with IBM Cloud for this. This has nothing to do with our module. It also looks like you might have escaped the apply early (maybe you hit ctrl + c) ? This is never a good idea in terraform. You should always allow terraform to timeout itself or it can corrupt your state file.

@lionelmace
Copy link

I tried and the terraform timed out after 1h10mins

module.postgresql_db.ibm_database.postgresql_db: Still creating... [1h11m20s elapsed]
module.postgresql_db.ibm_database.postgresql_db: Still creating... [1h11m30s elapsed]
╷
│ Error: [ERROR] Error waiting for database (crn:v1:bluemix:public:databases-for-postgresql:eu-de:a%2Fb41a28b85f604bf6b86986adb5117b13:fa9e04bb-f9be-4262-8182-d977d87aa22e::) configuration update task to complete: [Error] Time out waiting for database task to complete
│
│   with module.postgresql_db.ibm_database.postgresql_db,
│   on .terraform/modules/postgresql_db/main.tf line 55, in resource "ibm_database" "postgresql_db":
│   55: resource "ibm_database" "postgresql_db" {

Applying new configuration also hangs at 60%.

Here are the terraform scripts I used to test: https://github.com/lionelmace/ibmcloud-utils/tree/master/terraform/icd-postgres-modules

@hFti I agree with @ocofaigh . Please create a support case.

@lionelmace
Copy link

@ocofaigh The example in the module is incorrect. It should be fixed to reflect the following changes

It's failing as logical replication is not enabled . "wal_level" must be defined properly .

Make sure that your database is configured such that logical replication can be enabled. This means the wal_level needs to be set to logical. Also, max_replication_slots and max_wal_senders must be greater than 20.

You can refer below document too.
 https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database

The following example does work
https://github.com/lionelmace/ibmcloud-utils/blob/master/terraform/icd-postgres-modules/database-postgres.tf

@ocofaigh
Copy link
Member

ocofaigh commented Nov 8, 2024

@lionelmace yea there was an ICD backend schema bug. The old schema allowed hot_standby as a value and didn't allow replica. However the new schema now allows replica (which is the default) and doesn't allow hot_standby. We will update the example now

@ocofaigh
Copy link
Member

ocofaigh commented Nov 8, 2024

@lionelmace Actually it was fixed already in #514

@ocofaigh ocofaigh closed this as completed Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants