ptrdom commented on code in PR #534:
URL: 
https://github.com/apache/pekko-persistence-r2dbc/pull/534#discussion_r4398404248


##########
docs/src/test/resources/application-mariadb.conf:
##########
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: Apache-2.0
+
+pekko.persistence.journal.plugin = "pekko.persistence.r2dbc.journal"
+pekko.persistence.snapshot-store.plugin = "pekko.persistence.r2dbc.snapshot"
+pekko.persistence.state.plugin = "pekko.persistence.r2dbc.state"
+
+// #connection-settings
+pekko.persistence.r2dbc {
+  dialect = "mariadb"
+  connection-factory {
+    driver = "mariadb"
+    host = "localhost"
+    host = ${?DB_HOST}
+    port = 3306
+    database = "mysql"
+    database = ${?DB_NAME}
+    user = "root"
+    user = ${?DB_USER}
+    password = "root"
+    password = ${?DB_PASSWORD}
+
+    # ssl {

Review Comment:
   Good catch, and it was worse than that: r2dbc-mariadb ignores the generic 
`ssl` option, so with `ssl.enabled = on` the connection wasn't encrypted at 
all. In 1baffb5 the `ssl` settings are mapped to the options of the MariaDB 
driver:
   - `mode` `require`, `verify-ca` and `verify-full` to `sslMode` `TRUST`, 
`VERIFY_CA` and `VERIFY_FULL`, with `verify-full` when `mode` is empty, and 
`allow`, `prefer` and `tunnel` fail fast
   - `root-cert`, `cert`, `key` and `password` to `serverSslCert`, 
`clientSslCert`, `clientSslKey` and `clientSslPassword`
   
   I verified it through `ConnectionFactoryProvider` against a MariaDB with 
`require_secure_transport=ON`: `verify-ca` and `verify-full` connect with the 
right CA and fail with another CA, `require` connects without verifying the 
certificate, and a `REQUIRE X509` user connects only with the client 
certificate. The mapping is unit tested, CI doesn't run a TLS database. The 
commented block in `application-mariadb.conf` now uses `verify-ca`, which works 
as documented.
   
   The asyncer MySQL driver has the same mismatch (it reads `sslCa` and 
`sslKeyPassword`), which is separate from this PR.



##########
core/src/test/scala/org/apache/pekko/persistence/r2dbc/state/DurableStateStoreChangeHandlerSpec.scala:
##########
@@ -53,9 +53,9 @@ object DurableStateStoreChangeHandlerSpec {
 
   val dialect: String = config.getString("pekko.persistence.r2dbc.dialect")
 
-  // MySQL uses ? as parameter markers; Postgres/Yugabyte use $1, $2, $3
+  // MySQL and MariaDB use ? as parameter markers; Postgres/Yugabyte use $1, 
$2, $3
   private val insertSql: String =
-    if (dialect == "mysql") "insert into changes_test (pid, rev, the_value) 
values (?, ?, ?)"
+    if (dialect == "mysql" || dialect == "mariadb") "insert into changes_test 
(pid, rev, the_value) values (?, ?, ?)"
     else sql"insert into changes_test (pid, rev, the_value) values (?, ?, ?)"

Review Comment:
   Done in 1baffb5: `TestConfig.dialect` and `TestConfig.dialectSql(sql)`, 
which uses `Sql.DialectOps`, replace the string checks for the parameter 
markers, and the dialect specific checks match on `Dialect` values, so a new 
dialect gets a non-exhaustive match warning instead of a silent fallthrough.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to