Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public abstract class ConnectionConfig extends PluginConfig implements DatabaseC
public static final String CONNECTION_ARGUMENTS = "connectionArguments";
public static final String JDBC_PLUGIN_NAME = "jdbcPluginName";
public static final String JDBC_PLUGIN_TYPE = "jdbc";
public static final String TRANSACTION_ISOLATION_LEVEL = "transactionIsolationLevel";
public static final String ROLE = "role";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable ROLE ?


@Name(JDBC_PLUGIN_NAME)
@Description("Name of the JDBC driver to use. This is the value of the 'jdbcPluginName' key defined in the JSON " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.cdap.cdap.api.annotation.Macro;
import io.cdap.cdap.api.annotation.Name;
import io.cdap.plugin.db.ConnectionConfig;
import io.cdap.plugin.db.TransactionIsolationLevel;

import java.util.Collections;
import java.util.Map;
Expand All @@ -42,6 +43,13 @@ public abstract class AbstractDBSpecificConnectorConfig extends AbstractDBConnec
@Nullable
protected Integer port;


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove blank line

@Name(ConnectionConfig.TRANSACTION_ISOLATION_LEVEL)
@Description("The transaction isolation level for the database session.")
@Macro
@Nullable
protected String transactionIsolationLevel;

public String getHost() {
return host;
}
Expand All @@ -55,4 +63,11 @@ public int getPort() {
public boolean canConnect() {
return super.canConnect() && !containsMacro(ConnectionConfig.HOST) && !containsMacro(ConnectionConfig.PORT);
}

public String getTransactionIsolationLevel() {
if (transactionIsolationLevel == null) {
transactionIsolationLevel = TransactionIsolationLevel.Level.TRANSACTION_READ_COMMITTED.name();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in other plugins we dont have a default isolation level set by us as it can differ db wise, return null if it is null

}
return TransactionIsolationLevel.Level.valueOf(transactionIsolationLevel).name();
}
Comment on lines +68 to +86
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set the transactionIsolationLevel to TRANSACTION_READ_COMMITTED for normal roles just to ensure that the role is mapped to the right serialization level, even with incorrect user input?

//if role is SYSDBA or SYSOP it will map to read_committed. else serialized
    return (!getRole().equals(ROLE_NORMAL)) ? TransactionIsolationLevel.Level.TRANSACTION_READ_COMMITTED.name() :
            TransactionIsolationLevel.Level.valueOf(transactionIsolationLevel).name();

}
6 changes: 6 additions & 0 deletions mysql-plugin/docs/MySQL-connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ authentication. Optional for databases that do not require authentication.

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

**Transaction Isolation Level** The transaction isolation level of the databse connection
- TRANSACTION_READ_COMMITTED: No dirty reads. Non-repeatable reads and phantom reads are possible.
- TRANSACTION_SERIALIZABLE (default): No dirty reads. Non-repeatable and phantom reads are prevented.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this we are making default on UI then its fine

- TRANSACTION_REPEATABLE_READ: No dirty reads. Prevents non-repeatable reads, but phantom reads are still possible.
- TRANSACTION_READ_UNCOMMITTED: Allows dirty reads (reading uncommitted changes from other transactions). Non-repeatable reads and phantom reads are possible.

**Connection Arguments:** A list of arbitrary string tag/value pairs as connection arguments. These arguments
will be passed to the JDBC driver, as connection arguments, for JDBC drivers that may need additional configurations.
This is a semicolon-separated list of key-value pairs, where each pair is separated by a equals '=' and specifies
Expand Down
6 changes: 6 additions & 0 deletions mysql-plugin/docs/Mysql-batchsink.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ You also can use the macro function ${conn(connection-name)}.

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

**Transaction Isolation Level** The transaction isolation level of the databse connection
- TRANSACTION_READ_COMMITTED: No dirty reads. Non-repeatable reads and phantom reads are possible.
- TRANSACTION_SERIALIZABLE (default): No dirty reads. Non-repeatable and phantom reads are prevented.
- TRANSACTION_REPEATABLE_READ: No dirty reads. Prevents non-repeatable reads, but phantom reads are still possible.
- TRANSACTION_READ_UNCOMMITTED: Allows dirty reads (reading uncommitted changes from other transactions). Non-repeatable reads and phantom reads are possible.

**Connection Arguments:** A list of arbitrary string key/value pairs as connection arguments. These arguments
will be passed to the JDBC driver as connection arguments for JDBC drivers that may need additional configurations.

Expand Down
6 changes: 6 additions & 0 deletions mysql-plugin/docs/Mysql-batchsource.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ For example, 'SELECT MIN(id),MAX(id) FROM table'. Not required if numSplits is s

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

**Transaction Isolation Level** The transaction isolation level of the databse connection
- TRANSACTION_READ_COMMITTED: No dirty reads. Non-repeatable reads and phantom reads are possible.
- TRANSACTION_SERIALIZABLE (default): No dirty reads. Non-repeatable and phantom reads are prevented.
- TRANSACTION_REPEATABLE_READ: No dirty reads. Prevents non-repeatable reads, but phantom reads are still possible.
- TRANSACTION_READ_UNCOMMITTED: Allows dirty reads (reading uncommitted changes from other transactions). Non-repeatable reads and phantom reads are possible.

**Connection Arguments:** A list of arbitrary string key/value pairs as connection arguments. These arguments
will be passed to the JDBC driver as connection arguments for JDBC drivers that may need additional configurations.

Expand Down
14 changes: 14 additions & 0 deletions mysql-plugin/widgets/MySQL-connector.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@
"widget-attributes": {
"default": "3306"
}
},
{
"widget-type": "select",
"label": "Transaction Isolation Level",
"name": "transactionIsolationLevel",
"widget-attributes": {
"values": [
"TRANSACTION_READ_UNCOMMITTED",
"TRANSACTION_READ_COMMITTED",
"TRANSACTION_REPEATABLE_READ",
"TRANSACTION_SERIALIZABLE"
],
"default": "TRANSACTION_SERIALIZABLE"
}
}
]
},
Expand Down
18 changes: 18 additions & 0 deletions mysql-plugin/widgets/Mysql-batchsink.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@
"label": "Password",
"name": "password"
},
{
"widget-type": "select",
"label": "Transaction Isolation Level",
"name": "transactionIsolationLevel",
"widget-attributes": {
"values": [
"TRANSACTION_READ_UNCOMMITTED",
"TRANSACTION_READ_COMMITTED",
"TRANSACTION_REPEATABLE_READ",
"TRANSACTION_SERIALIZABLE"
],
"default": "TRANSACTION_SERIALIZABLE"
}
},
{
"widget-type": "keyvalue",
"label": "Connection Arguments",
Expand Down Expand Up @@ -225,6 +239,10 @@
"type": "property",
"name": "password"
},
{
"type": "property",
"name": "transactionIsolationLevel"
},
{
"type": "property",
"name": "host"
Expand Down
18 changes: 18 additions & 0 deletions mysql-plugin/widgets/Mysql-batchsource.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@
"label": "Password",
"name": "password"
},
{
"widget-type": "select",
"label": "Transaction Isolation Level",
"name": "transactionIsolationLevel",
"widget-attributes": {
"values": [
"TRANSACTION_READ_UNCOMMITTED",
"TRANSACTION_READ_COMMITTED",
"TRANSACTION_REPEATABLE_READ",
"TRANSACTION_SERIALIZABLE"
],
"default": "TRANSACTION_SERIALIZABLE"
}
},
{
"widget-type": "keyvalue",
"label": "Connection Arguments",
Expand Down Expand Up @@ -277,6 +291,10 @@
"type": "property",
"name": "password"
},
{
"type": "property",
"name": "transactionIsolationLevel"
},
{
"type": "property",
"name": "host"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ public String getConnectionString() {
@Macro
private String database;

@Name(OracleConstants.TRANSACTION_ISOLATION_LEVEL)
@Description("The transaction isolation level for the database session.")
@Macro
@Nullable
private String transactionIsolationLevel;

@Name(OracleConstants.USE_SSL)
@Description("Turns on SSL encryption. Connection will fail if SSL is not available")
@Nullable
Expand Down Expand Up @@ -133,7 +127,7 @@ public String getTransactionIsolationLevel() {
//This ensures that the role is mapped to the right serialization level, even w/ incorrect user input
//if role is SYSDBA or SYSOP it will map to read_committed. else serialized
return (!getRole().equals(ROLE_NORMAL)) ? TransactionIsolationLevel.Level.TRANSACTION_READ_COMMITTED.name() :
TransactionIsolationLevel.Level.valueOf(transactionIsolationLevel).name();
TransactionIsolationLevel.Level.valueOf(transactionIsolationLevel).name();
}

@Override
Expand Down
5 changes: 5 additions & 0 deletions postgresql-plugin/docs/PostgreSQL-connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ authentication. Optional for databases that do not require authentication.

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

**Transaction Isolation Level** The transaction isolation level of the databse connection
- TRANSACTION_READ_COMMITTED: No dirty reads. Non-repeatable reads and phantom reads are possible.
- TRANSACTION_SERIALIZABLE (default): No dirty reads. Non-repeatable and phantom reads are prevented.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- TRANSACTION_REPEATABLE_READ: No dirty reads. Prevents non-repeatable reads, but phantom reads are still possible.

**Database:** The name of the database to connect to.

**Connection Arguments:** A list of arbitrary string tag/value pairs as connection arguments. These arguments
Expand Down
5 changes: 5 additions & 0 deletions postgresql-plugin/docs/Postgres-batchsink.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ You also can use the macro function ${conn(connection-name)}.

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

**Transaction Isolation Level** The transaction isolation level of the databse connection
- TRANSACTION_READ_COMMITTED: No dirty reads. Non-repeatable reads and phantom reads are possible.
- TRANSACTION_SERIALIZABLE (default): No dirty reads. Non-repeatable and phantom reads are prevented.
- TRANSACTION_REPEATABLE_READ: No dirty reads. Prevents non-repeatable reads, but phantom reads are still possible.

**Connection Arguments:** A list of arbitrary string key/value pairs as connection arguments. These arguments
will be passed to the JDBC driver as connection arguments for JDBC drivers that may need additional configurations.

Expand Down
5 changes: 5 additions & 0 deletions postgresql-plugin/docs/Postgres-batchsource.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ For example, 'SELECT MIN(id),MAX(id) FROM table'. Not required if numSplits is s

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

**Transaction Isolation Level** The transaction isolation level of the databse connection
- TRANSACTION_READ_COMMITTED: No dirty reads. Non-repeatable reads and phantom reads are possible.
- TRANSACTION_SERIALIZABLE (default): No dirty reads. Non-repeatable and phantom reads are prevented.
- TRANSACTION_REPEATABLE_READ: No dirty reads. Prevents non-repeatable reads, but phantom reads are still possible.

**Connection Arguments:** A list of arbitrary string key/value pairs as connection arguments. These arguments
will be passed to the JDBC driver as connection arguments for JDBC drivers that may need additional configurations.

Expand Down
13 changes: 13 additions & 0 deletions postgresql-plugin/widgets/PostgreSQL-connector.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@
"default": "5432"
}
},
{
"widget-type": "select",
"label": "Transaction Isolation Level",
"name": "transactionIsolationLevel",
"widget-attributes": {
"values": [
"TRANSACTION_READ_COMMITTED",
"TRANSACTION_REPEATABLE_READ",
"TRANSACTION_SERIALIZABLE"
],
"default": "TRANSACTION_SERIALIZABLE"
}
},
{
"widget-type": "textbox",
"label": "Database",
Expand Down
17 changes: 17 additions & 0 deletions postgresql-plugin/widgets/Postgres-batchsink.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@
"label": "Password",
"name": "password"
},
{
"widget-type": "select",
"label": "Transaction Isolation Level",
"name": "transactionIsolationLevel",
"widget-attributes": {
"values": [
"TRANSACTION_READ_COMMITTED",
"TRANSACTION_REPEATABLE_READ",
"TRANSACTION_SERIALIZABLE"
],
"default": "TRANSACTION_SERIALIZABLE"
}
},
{
"widget-type": "keyvalue",
"label": "Connection Arguments",
Expand Down Expand Up @@ -186,6 +199,10 @@
"type": "property",
"name": "port"
},
{
"type": "property",
"name": "transactionIsolationLevel"
},
{
"type": "property",
"name": "database"
Expand Down
17 changes: 17 additions & 0 deletions postgresql-plugin/widgets/Postgres-batchsource.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@
"label": "Password",
"name": "password"
},
{
"widget-type": "select",
"label": "Transaction Isolation Level",
"name": "transactionIsolationLevel",
"widget-attributes": {
"values": [
"TRANSACTION_READ_COMMITTED",
"TRANSACTION_REPEATABLE_READ",
"TRANSACTION_SERIALIZABLE"
],
"default": "TRANSACTION_SERIALIZABLE"
}
},
{
"widget-type": "keyvalue",
"label": "Connection Arguments",
Expand Down Expand Up @@ -206,6 +219,10 @@
"type": "property",
"name": "port"
},
{
"type": "property",
"name": "transactionIsolationLevel"
},
{
"type": "property",
"name": "database"
Expand Down