diff --git a/Makefile b/Makefile
index 4f7dae1b44..dd6afda905 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ endif
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
-VERSION ?= 26.6.0-bandwidth.5
+VERSION ?= 26.6.0-bandwidth.6
# mariadb-operator
IMG_NAME ?= ghcr.io/mariadb-operator/mariadb-operator
diff --git a/docs/docker.md b/docs/docker.md
index cbc1544efe..81eac0c5c5 100644
--- a/docs/docker.md
+++ b/docs/docker.md
@@ -36,7 +36,7 @@
| MariaDB Operator |
- ghcr.io/mariadb-operator/mariadb-operator:26.6.0-bandwidth.5 |
+ ghcr.io/mariadb-operator/mariadb-operator:26.6.0-bandwidth.6 |
amd64 arm64 |
diff --git a/examples/manifests/mariadb_replication.yaml b/examples/manifests/mariadb_replication.yaml
index c5565cbcda..7379a817ae 100644
--- a/examples/manifests/mariadb_replication.yaml
+++ b/examples/manifests/mariadb_replication.yaml
@@ -66,10 +66,10 @@ spec:
# syncBinlog: 1
# Init container that cooperates with mariadb-operator.
# initContainer:
- # image: ghcr.io/mariadb-operator/mariadb-operator:26.6.0-bandwidth.5
+ # image: ghcr.io/mariadb-operator/mariadb-operator:26.6.0-bandwidth.6
# Agent sidecar that cooperates with mariadb-operator.
# agent:
- # image: ghcr.io/mariadb-operator/mariadb-operator:26.6.0-bandwidth.5
+ # image: ghcr.io/mariadb-operator/mariadb-operator:26.6.0-bandwidth.6
service:
type: LoadBalancer
diff --git a/internal/controller/mariadb_controller_external_repl_init.go b/internal/controller/mariadb_controller_external_repl_init.go
index 35d47daebc..70f55f605c 100644
--- a/internal/controller/mariadb_controller_external_repl_init.go
+++ b/internal/controller/mariadb_controller_external_repl_init.go
@@ -377,7 +377,26 @@ func getBinlogExpireLogsDuration(emdb *mariadbv1alpha1.ExternalMariaDB, ctx cont
var binlogExpireLogsSecondsStr string
var binlogExpireLogsSeconds int
- if semver.Compare("v"+emdb.Status.Version, "v10.6.1") >= 0 {
+ isRDS := false
+
+ // Check if it is an RDS instance
+ if user_exist, err := external_client.UserExists(ctx, "rdsadmin", "localhost"); err != nil && user_exist {
+ if table_exists, err := external_client.TableExists(ctx, "mysql", "rds_configuration"); err != nil && table_exists {
+ logger.Info("RDS config found")
+ isRDS = true
+ }
+ logger.Info("AWS user detected")
+ }
+
+ if isRDS {
+ logger.Info("Using 'binlog retention hours' in mysql.rds_configuration", "version", emdb.Status.Version)
+ binlogExpireLogsHourStr, err := external_client.RDSConfiguration(ctx, "binlog retention hours")
+ if err != nil {
+ return time.Duration(0), fmt.Errorf("unable to get 'binlog retention hours' from RDS instance: %v", err)
+ }
+ binlogExpireLogsHour, _ := strconv.Atoi(binlogExpireLogsHourStr)
+ binlogExpireLogsSeconds = binlogExpireLogsHour * 3600
+ } else if semver.Compare("v"+emdb.Status.Version, "v10.6.1") >= 0 {
logger.Info("Using binlog_expire_logs_seconds", "version", emdb.Status.Version)
binlogExpireLogsSecondsStr, err = external_client.SystemVariable(ctx, "binlog_expire_logs_seconds")
if err != nil {
diff --git a/pkg/sql/sql.go b/pkg/sql/sql.go
index 582d474f39..c611e1abeb 100644
--- a/pkg/sql/sql.go
+++ b/pkg/sql/sql.go
@@ -598,6 +598,22 @@ func (c *Client) UserExists(ctx context.Context, username, host string) (bool, e
return count > 0, nil
}
+func (c *Client) TableExists(ctx context.Context, schema string, table string) (bool, error) {
+
+ row := c.db.QueryRowContext(ctx, `
+ SELECT COUNT(*) AS table_exists
+ FROM information_schema.tables
+ WHERE
+ table_schema = ?
+ AND table_name = ?;
+ `, schema, table)
+ var count int
+ if err := row.Scan(&count); err != nil {
+ return false, err
+ }
+ return count > 0, nil
+}
+
func (c *Client) GrantExists(ctx context.Context,
privileges []string,
database string,
@@ -778,6 +794,17 @@ func (c *Client) SystemVariable(ctx context.Context, variable string) (string, e
return val, nil
}
+func (c *Client) RDSConfiguration(ctx context.Context, config string) (string, error) {
+ sql := fmt.Sprintf("SELECT value FROM mysql.rds_configuration WHERE name = '%s';", config)
+ row := c.db.QueryRowContext(ctx, sql)
+
+ var val string
+ if err := row.Scan(&val); err != nil {
+ return "", nil
+ }
+ return val, nil
+}
+
func (c *Client) IsSystemVariableEnabled(ctx context.Context, variable string) (bool, error) {
val, err := c.SystemVariable(ctx, variable)
if err != nil {