Skip to content

Commit

Permalink
Merge branch 'release/1.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed May 12, 2022
2 parents 0ce9db3 + c07d241 commit fa6bdbf
Show file tree
Hide file tree
Showing 242 changed files with 9,214 additions and 4,481 deletions.
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
os: linux
dist: focal
language: java
services: docker
services:
- docker
- mysql
jdk: openjdk11
addons:
hosts:
Expand All @@ -10,7 +12,7 @@ addons:

before_install:
- git clone https://github.com/mariadb-corporation/connector-test-machine.git
env: packet=40
env: packet=40 local=0 clear_text_plugin=0 RUN_LONG_TEST=true
install:
- |-
case $TRAVIS_OS_NAME in
Expand All @@ -20,7 +22,7 @@ install:
connector-test-machine/launch.bat -t "$srv" -v "$v" -d testr2
;;
linux)
source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testr2 -n 0 -l "$local" -p "$packet"
source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testr2 -n 0 -l "$local" -p "$packet" -c "$clear_text_plugin"
;;
esac
Expand All @@ -37,16 +39,14 @@ jobs:
- env: srv=mariadb v=10.3 local=1
- env: srv=mariadb v=10.4 local=1
- env: srv=mariadb v=10.5 local=1
- env: srv=mariadb v=10.5 local=1
jdk: openjdk8
dist: bionic
- env: srv=mariadb v=10.6 local=1
- env: srv=mariadb v=10.5 NO_BACKSLASH_ESCAPES=true
- env: srv=mariadb v=10.7 local=1 clear_text_plugin=1
- env: srv=mariadb v=10.6 NO_BACKSLASH_ESCAPES=true
- env: srv=mariadb v=10.6 BENCH=1
- if: type = push AND fork = false
env: srv=maxscale
- if: type = push AND fork = false
env: srv=mariadb-es v=10.5
env: srv=mariadb-es v=10.6
- if: type = push AND fork = false
env: srv=skysql
- if: type = push AND fork = false
Expand Down
31 changes: 30 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Change Log

## [1.1.2](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/tree/1.1.2) (12 Mai 2022)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/compare/1.1.1...1.1.2)

* [R2DBC-54] Support r2dbc spec 0.9.1 version
* [R2DBC-42] Specification precision on Statement::add
* [R2DBC-44] simplify client side prepared statement
* [R2DBC-45] Implement SPI TestKit to validate driver with spec tests
* [R2DBC-46] Add sql to R2DBC exception hierarchy
* [R2DBC-47] ensure driver follow spec precision about Row.get returning error.
* [R2DBC-48] after spec batch clarification trailing batch should fail
* [R2DBC-49] Support for failover and load balancing modes
* [R2DBC-50] TIME data without indication default to return Duration in place of LocalTime
* [R2DBC-56] Transaction isolation spec precision
* [R2DBC-57] varbinary data default must return byte[]
* [R2DBC-63] backpressure handling
* [R2DBC-64] Support batch cancellation
* [R2DBC-53] correct RowMetadata case-sensitivity lookup
* [R2DBC-62] Prepared statement wrong column type on prepare meta not skipped

## [1.1.1-rc](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/tree/1.1.1) (13 Sept 2021)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/compare/1.1.0...1.1.1)

Changes:
* [R2DBC-37] Full java 9 JPMS module
* [R2DBC-38] Permit sharing channels with option loopResources

Corrections:
* [R2DBC-40] netty buffer leaks when not consuming results
* [R2DBC-39] MariadbResult.getRowsUpdated() fails with ClassCastException for RETURNING command

## [1.0.3](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/tree/1.0.3) (13 Sept 2021)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/compare/1.0.2...1.0.3)
Expand Down Expand Up @@ -86,4 +115,4 @@ Changes compared to 0.8.2.alpha1:
second Alpha release

## [0.8.1](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/tree/0.8.1) (23 Mar. 2020)
First Alpha release
First Alpha release
58 changes: 49 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ MariaDB and MySQL client, 100% Java, compatible with Java8+, apache 2.0 licensed
- Driver permits ed25519, PAM authentication that comes with MariaDB.
- use MariaDB 10.5 returning fonction to permit Statement.returnGeneratedValues

Driver follow [R2DBC 0.8.4 specifications](https://r2dbc.io/spec/0.8.4.RELEASE/spec/html/)
Driver follow [R2DBC 0.9.1 specifications](https://r2dbc.io/spec/0.9.1.RELEASE/spec/html/)

## Documentation

Expand All @@ -32,7 +32,7 @@ The MariaDB Connector is available through maven using :
<dependency>
<groupId>org.mariadb</groupId>
<artifactId>r2dbc-mariadb</artifactId>
<version>1.0.3</version>
<version>1.1.2</version>
</dependency>
```

Expand All @@ -52,7 +52,7 @@ MariadbConnectionFactory factory = new MariadbConnectionFactory(conf);

//OR

ConnectionFactory factory = ConnectionFactories.get("r2dbc:mariadb://user:password@host:3306/myDB?option1=value");
ConnectionFactory factory = ConnectionFactories.get("r2dbc:mariadb://user:password@host:3306,host2:3302/myDB?option1=value");
```

Basic example:
Expand Down Expand Up @@ -82,7 +82,7 @@ Basic example:
|---:|---|:---:|:---:|
| **`username`** | User to access database. |*string* |
| **`password`** | User password. |*string* |
| **`host`** | IP address or DNS of the database server. *Not used when using option `socketPath`*. |*string*| "localhost"|
| **`host`** | IP address or DNS of the database server. Multiple host can be set, separate by comma. If first host is not reachable (timeout is connectTimeout), driver use next hosts.*Not used when using option `socketPath`*. |*string*| "localhost"|
| **`port`** | Database server port number. *Not used when using option `socketPath`*|*integer*| 3306|
| **`database`** | Default database to use when establishing the connection. | *string* |
| **`connectTimeout`** | Sets the connection timeout | *Duration* | 10s|
Expand All @@ -108,13 +108,53 @@ Basic example:
| **`pamOtherPwd`** | Permit to provide additional password for PAM authentication with multiple authentication step. If multiple passwords, value must be URL encoded.|*string* | |
| **`autocommit`** | Set default autocommit value on connection initialization" |*boolean* | true |
| **`tinyInt1isBit`** | Convert Bit(1)/TINYINT(1) default to boolean type |*boolean* | true |
| **`restrictedAuth`** | if set, restrict authentication plugin to secure list. Default provided plugins are mysql_native_password, mysql_clear_password, client_ed25519, dialog, sha256_password and caching_sha2_password |*string* | |
| **`loopResources`** | permits to share netty EventLoopGroup among multiple async libraries/framework |*LoopResources* | |

## Roadmap
## Failover

* Performance !
* Fast batch using mariadb bulk
* GeoJSON datatype
* Pluggable types for MariaDB 10.5 (JSON, INET4, INET6, BOOLEAN, ...)
Failover occurs when a connection to a primary database server fails and the connector opens up a connection to another database server.
For example, server A has the current connection. After a failure (server crash, network down …) the connection will switch to another server (B).

Load balancing allows load to be distributed over multiple servers :
When initializing a connection or after a failed connection, the connector will attempt to connect to a host. The connection is selected randomly among the valid hosts. Thereafter, all statements will run on that database server until the connection will be closed (or fails).
Example: when creating a pool of 60 connections, each one will use a random host. With 3 master hosts, the pool will have about 20 connections to each host.

```java
ConnectionFactory factory = ConnectionFactories.get("r2dbc:mariadb:sequential://user:password@host:3306,host2:3302/myDB?option1=value");
```


### Failover behaviour

Failover parameter is set (i.e. prefixing connection string with `r2dbc:mariadb:[sequential|loadbalancing]://...` or using HaMode builder).

There can be multiple fail causes. When a failure occurs many things will be done:

* connection recovery (re-establishing connection transparently)
* re-execute command/transaction if possible

During failover, the fail host address will be put on a blacklist (shared by JVM) for 60 seconds. Connector will always try to connect non blacklisted host first, but can retry to connect blacklisted host before 60s if all hosts are blacklisted.

### re-execution
The driver will try to reconnect to any valid host (not blasklisted, or if all primary host are blacklisted trying blacklisted hosts). If reconnection fail, an Exception with be thrown with SQLState "08XXX". If using a pool, this connection will be discarded.

on successful reconnection, there will be different cases.

If driver identify that command can be replayed without issue (for example connection.isValid(), a PREPARE/ROLLBACK command), driver will execute command without throwing any error.

Driver cannot transparently handle all cases : imagine that the failover occurs when executing an INSERT command without a transaction: driver cannot know that command has been received and executed on server. In those case, an SQLException with be thrown with SQLState "25S03".

#### Option `transactionReplay` :
Most of the time, queries occurs in transaction (ORM for example doesn't permit using auto-commit), so redo transaction implementation will solve most of failover cases transparently for user point of view.

Redo transaction approach is to save commands in transaction. When a failover occurs during a transaction, the connector can automatically reconnect and replay transaction, making failover completely transparent.

There is some limitations :

driver will buffer up commands in a transaction until some inner limit.
huge command will temporarily disable transaction buffering for current transaction.
Commands must be idempotent only (queries can be "replayable")


## Tracker
Expand Down
4 changes: 2 additions & 2 deletions intellij-style.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
~ SPDX-License-Identifier: Apache-2.0
~ Copyright (c) 2020-2021 MariaDB Corporation Ab
~ Copyright (c) 2020-2022 MariaDB Corporation Ab
-->

<code_scheme name="Project" version="173">
Expand Down Expand Up @@ -451,4 +451,4 @@
<codeStyleSettings language="TypeScript">
<option name="WRAP_COMMENTS" value="true"/>
</codeStyleSettings>
</code_scheme>
</code_scheme>
94 changes: 64 additions & 30 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
~ SPDX-License-Identifier: Apache-2.0
~ Copyright (c) 2020-2021 MariaDB Corporation Ab
~ Copyright (c) 2020-2022 MariaDB Corporation Ab
-->

<project
Expand All @@ -11,7 +11,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.mariadb</groupId>
<artifactId>r2dbc-mariadb</artifactId>
<version>1.0.3</version>
<version>1.1.2</version>
<packaging>jar</packaging>
<url>https://github.com/mariadb-corporation/mariadb-connector-r2dbc</url>

Expand All @@ -21,14 +21,14 @@
<properties>
<java.version>1.8</java.version>
<jsr305.version>3.0.2</jsr305.version>
<junit.version>5.7.2</junit.version>
<jmh.version>1.32</jmh.version>
<logback.version>1.2.3</logback.version>
<netty.version>4.1.65.Final</netty.version>
<junit.version>5.8.2</junit.version>
<jmh.version>1.34</jmh.version>
<logback.version>1.2.10</logback.version>
<netty.version>4.1.73.Final</netty.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<r2dbc-spi.version>0.8.5.RELEASE</r2dbc-spi.version>
<reactor.version>Dysprosium-SR21</reactor.version>
<mariadb-jdbc.version>3.0.0-alpha</mariadb-jdbc.version>
<r2dbc-spi.version>0.9.1.RELEASE</r2dbc-spi.version>
<reactor.version>2020.0.15</reactor.version>
<mariadb-jdbc.version>3.0.4</mariadb-jdbc.version>
<uberjar.name>benchmarks</uberjar.name>
</properties>

Expand Down Expand Up @@ -97,12 +97,26 @@
</dependencies>
</dependencyManagement>

<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-spi</artifactId>
<version>${r2dbc-spi.version}</version>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-spi-test</artifactId>
<version>${r2dbc-spi.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
Expand Down Expand Up @@ -134,16 +148,6 @@
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.junit.jupiter</groupId>-->
<!-- <artifactId>junit-jupiter-api</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.junit.jupiter</groupId>-->
<!-- <artifactId>junit-jupiter-params</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand All @@ -155,6 +159,12 @@
<version>${logback.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>${mariadb-jdbc.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -165,17 +175,41 @@
<version>3.8.1</version>
<configuration>
<compilerArgs>
<arg>-Xlint:all,-options,-path,-processing</arg>
<arg>-Xlint:all,-options,-path,-processing,-requires-transitive-automatic,-requires-automatic</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<executions>
<execution>
<id>compile-java-8</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>compile-java-9</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>9</release>
<source>9</source>
<target>9</target>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
Expand All @@ -184,7 +218,7 @@
</manifest>
<manifestEntries>
<R2DBC-Specification-Version>${r2dbc-spi.version}</R2DBC-Specification-Version>
<Automatic-Module-Name>r2dbc.mariadb</Automatic-Module-Name>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
Expand Down Expand Up @@ -305,7 +339,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<version>0.8.7</version>
<configuration>
<excludes>
<exclude>**/ed25519/**/*.class</exclude>
Expand Down Expand Up @@ -342,16 +376,16 @@
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>${mariadb-jdbc.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>${mariadb-jdbc.version}</version>
</dependency>
</dependencies>

<build>
Expand All @@ -369,7 +403,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<version>3.3.0</version>
<executions>
<execution>
<id>add-source</id>
Expand Down Expand Up @@ -402,7 +436,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
Loading

0 comments on commit fa6bdbf

Please sign in to comment.