Skip to content

Commit 590e4c3

Browse files
Merge pull request #676 from cloudsufi/transaction-level-isolation-cherrypick-1.12
[🍒] Add TRANSACTION_ISOLATION_LEVEL config in cloudsql-postgres and cloudsql-mysql plugins for release/1.12
2 parents 7beed53 + 505bf54 commit 590e4c3

32 files changed

Lines changed: 132 additions & 21 deletions

File tree

amazon-redshift-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>database-plugins-parent</artifactId>
2222
<groupId>io.cdap.plugin</groupId>
23-
<version>1.12.4</version>
23+
<version>1.12.5-SNAPSHOT</version>
2424
</parent>
2525

2626
<name>Amazon Redshift plugin</name>

aurora-mysql-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>database-plugins-parent</artifactId>
2222
<groupId>io.cdap.plugin</groupId>
23-
<version>1.12.4</version>
23+
<version>1.12.5-SNAPSHOT</version>
2424
</parent>
2525

2626
<name>Aurora DB MySQL plugin</name>

aurora-postgresql-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>database-plugins-parent</artifactId>
2222
<groupId>io.cdap.plugin</groupId>
23-
<version>1.12.4</version>
23+
<version>1.12.5-SNAPSHOT</version>
2424
</parent>
2525

2626
<name>Aurora DB PostgreSQL plugin</name>

cloudsql-mysql-plugin/docs/CloudSQLMySQL-batchsink.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Can be found in the instance overview page.
4242

4343
**Password:** Password to use to connect to the specified database.
4444

45-
**Transaction Isolation Level:** Transaction isolation level for queries run by this sink.
45+
**Transaction Isolation Level:** Transaction isolation level for queries run by this sink.
4646

4747
**Connection Timeout:** The timeout value (in seconds) used for socket connect operations. If connecting to the server
4848
takes longer than this value, the connection is broken. A value of 0 means that it is disabled.

cloudsql-mysql-plugin/docs/CloudSQLMySQL-batchsource.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ For example, 'SELECT MIN(id),MAX(id) FROM table'. Not required if numSplits is s
5252

5353
**Password:** Password to use to connect to the specified database.
5454

55+
**Transaction Isolation Level:** The transaction isolation level of the database connection.
56+
- TRANSACTION_READ_COMMITTED: No dirty reads. Non-repeatable reads and phantom reads are possible.
57+
- TRANSACTION_SERIALIZABLE: No dirty reads. Non-repeatable and phantom reads are prevented.
58+
- TRANSACTION_REPEATABLE_READ: No dirty reads. Prevents non-repeatable reads, but phantom reads are still possible.
59+
- TRANSACTION_READ_UNCOMMITTED: Allows dirty reads (reading uncommitted changes from other transactions). Non-repeatable reads and phantom reads are possible.
60+
61+
For more details on the Transaction Isolation Levels supported in CloudSQL MySQL, refer to the [CloudSQL MySQL documentation](https://dev.mysql.com/doc/refman/8.0/en/innodb-transaction-isolation-levels.html)
62+
5563
**Connection Arguments:** A list of arbitrary string key/value pairs as connection arguments. These arguments
5664
will be passed to the JDBC driver as connection arguments for JDBC drivers that may need additional configurations.
5765

cloudsql-mysql-plugin/docs/CloudSQLMySQL-connector.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ authentication. Optional for databases that do not require authentication.
2727

2828
**Password:** Password to use to connect to the specified database.
2929

30+
**Transaction Isolation Level:** The transaction isolation level of the database connection.
31+
- TRANSACTION_READ_COMMITTED: No dirty reads. Non-repeatable reads and phantom reads are possible.
32+
- TRANSACTION_SERIALIZABLE: No dirty reads. Non-repeatable and phantom reads are prevented.
33+
- TRANSACTION_REPEATABLE_READ: No dirty reads. Prevents non-repeatable reads, but phantom reads are still possible.
34+
- TRANSACTION_READ_UNCOMMITTED: Allows dirty reads (reading uncommitted changes from other transactions). Non-repeatable reads and phantom reads are possible.
35+
36+
For more details on the Transaction Isolation Levels supported in CloudSQL MySQL, refer to the [CloudSQL MySQL documentation](https://dev.mysql.com/doc/refman/8.0/en/innodb-transaction-isolation-levels.html)
37+
3038
**Connection Arguments:** A list of arbitrary string tag/value pairs as connection arguments. These arguments
3139
will be passed to the JDBC driver, as connection arguments, for JDBC drivers that may need additional configurations.
3240
This is a semicolon-separated list of key-value pairs, where each pair is separated by a equals '=' and specifies

cloudsql-mysql-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>database-plugins-parent</artifactId>
2222
<groupId>io.cdap.plugin</groupId>
23-
<version>1.12.4</version>
23+
<version>1.12.5-SNAPSHOT</version>
2424
</parent>
2525

2626
<name>CloudSQL MySQL plugin</name>

cloudsql-mysql-plugin/src/main/java/io/cdap/plugin/cloudsql/mysql/CloudSQLMySQLSource.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ public static class CloudSQLMySQLSourceConfig extends AbstractDBSpecificSourceCo
152152
@Description("The existing connection to use.")
153153
private CloudSQLMySQLConnectorConfig connection;
154154

155+
@Name(TRANSACTION_ISOLATION_LEVEL)
156+
@Description("Transaction isolation level for queries run by this source.")
157+
@Nullable
158+
private String transactionIsolationLevel;
159+
160+
private static final String DEFAULT_TRANSACTION_ISOLATION_LEVEL = "TRANSACTION_REPEATABLE_READ";
161+
155162
@Override
156163
protected Map<String, String> getDBSpecificArguments() {
157164
if (getFetchSize() == null || getFetchSize() <= 0) {
@@ -164,6 +171,11 @@ protected Map<String, String> getDBSpecificArguments() {
164171
return arguments;
165172
}
166173

174+
@Override
175+
public String getTransactionIsolationLevel() {
176+
return transactionIsolationLevel != null ? transactionIsolationLevel : DEFAULT_TRANSACTION_ISOLATION_LEVEL;
177+
}
178+
167179
@Override
168180
public void validate(FailureCollector collector) {
169181
ConfigUtil.validateConnection(this, useConnection, connection, collector);

cloudsql-mysql-plugin/widgets/CloudSQLMySQL-batchsource.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@
8484
"label": "Password",
8585
"name": "password"
8686
},
87+
{
88+
"widget-type": "select",
89+
"label": "Transaction Isolation Level",
90+
"name": "transactionIsolationLevel",
91+
"widget-attributes": {
92+
"default": "TRANSACTION_REPEATABLE_READ",
93+
"values": [
94+
"TRANSACTION_REPEATABLE_READ",
95+
"TRANSACTION_READ_UNCOMMITTED",
96+
"TRANSACTION_READ_COMMITTED",
97+
"TRANSACTION_SERIALIZABLE"
98+
]
99+
}
100+
},
87101
{
88102
"widget-type": "keyvalue",
89103
"label": "Connection Arguments",

cloudsql-mysql-plugin/widgets/CloudSQLMySQL-connector.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@
5454
"widget-attributes": {
5555
"default": "3306"
5656
}
57+
},
58+
{
59+
"widget-type": "select",
60+
"label": "Transaction Isolation Level",
61+
"name": "transactionIsolationLevel",
62+
"widget-attributes": {
63+
"default": "TRANSACTION_REPEATABLE_READ",
64+
"values": [
65+
"TRANSACTION_REPEATABLE_READ",
66+
"TRANSACTION_READ_UNCOMMITTED",
67+
"TRANSACTION_READ_COMMITTED",
68+
"TRANSACTION_SERIALIZABLE"
69+
]
70+
}
5771
}
5872
]
5973
},

0 commit comments

Comments
 (0)