GBase 8a, the MPP analytical database from Chinese vendor GBASE, locks an account after a configurable number of failed login attempts (login_attempt_max). That creates a real operational trap: after you change the database password, any application, cron job, script, ETL task, or middleware that keeps retrying with the old password can lock the account. This post covers several ways to rotate passwords in gbase with minimal impact on your applications.
The core of every solution is the same: each time an application opens a new connection, it must be able to fetch the latest password. One helpful detail specific to gbase: changing the password does not affect existing connections — they keep working; only new connections are verified against the new password.
In all the approaches below, passwords are stored encrypted, never in plain text. The encryption scheme is up to you — typically AES/SM4 symmetric encryption, or a designated endpoint such as a REST API that handles encryption and decryption centrally.
Option 1: A Shared Configuration File
Works well for private networks and small-scale deployments.
- Setup: keep the password configuration file on a shared file system, accessed via NFS, https, or sftp (slower).
- Read: all applications read the access password from that file.
- Change: after the DBA updates the database password, update the config file.
For the gap between the password change and the file update:
- The update itself is fast — an atomic rename overwrite completes in milliseconds.
- Use a convention like flock to briefly block reads while the file is being written.
- Temporarily revoke read permission on the file and restore it after the update (recommended).
If a read fails, retry with a short delay — far easier to handle than a locked database account.
Option 2: A Configuration Center
A good fit for small-to-medium setups. Store the password in Nacos, Apollo, Spring Cloud Config (Java), Consul, or a similar product.
- Setup: the database credentials live in an encrypted configuration item.
- Read: applications subscribe to configuration changes; updates are pushed automatically and connection pools refresh in real time.
- Change flow:
- The DBA changes the database user password.
- Operations updates the encrypted password in the configuration center.
- All running applications pick up the change automatically; new connections use the new password.
- Old connections drain and release naturally.
The same gap-handling advice applies: allow delayed retries after an error, but never let retries lock the database account.
Option 3: Store the Password Inside the Database
Keep the (symmetrically encrypted) password in a dedicated table, read through a general-purpose account that can only read that table — and whose password never needs to change.
- Setup: a separate database and a separate table used solely for password storage. Each password can carry a status field — active or updating — where updating means temporarily unavailable.
- Read: the dedicated user can only read that one table; applications fetch the encrypted password, decrypt it, and connect.
- Change: wrap the password change and the config-table update in one stored procedure:
- Mark the password entry as updating.
- Change the password. On failure, flip the entry back to active, notify a human, and return.
- Update the config table and set the status back to active; return on success.
- If the config table update fails even after retries, escalate to a human.
Option 4: Third-Party Authentication
For example, a KMS product or HashiCorp Vault.
- Setup: passwords are stored as secrets in the KMS.
- Read: clients fetch the latest password from the KMS.
- Change:
- An administrator initiates a password change / rotation request through the KMS.
- The KMS connects to the database and changes the password. If that fails, the KMS keeps serving the previous password.
- The KMS updates its local copy; if that fails, a human steps in.
Looking at real projects, any environment where multiple applications share credentials faces this problem — not just database passwords. Third-party solutions like a KMS or a configuration center are the most rigorous approach, and replacing fixed passwords with dynamic certificates such as Kerberos is also worth considering. For small deployments, a shared file is the simplest option; if you would rather not run an extra service, storing encrypted passwords in the database itself is a pragmatic and viable choice.
