Skip to content

Commit 0ef95e0

Browse files
Merge pull request #258 from jster1357/develop
add isolation level to Oracle Plugin: PLUGIN-1178
2 parents b2b24c0 + e96c19a commit 0ef95e0

9 files changed

Lines changed: 116 additions & 4 deletions

File tree

oracle-plugin/docs/Oracle-batchsink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ You also can use the macro function ${conn(connection-name)}.
3030

3131
**Role** Login role of the user when connecting to the database. For eg, NORMAL, SYSDBA, SYSOPER, etc.
3232

33+
**Transaction Isolation Level** The transaction isolation level of the databse connection
34+
- TRANSACTION_READ_COMMITTED: No dirty reads. Non-repeatable reads and phantom reads are possible.
35+
- TRANSACTION_SERIALIZABLE (default): No dirty reads. Non-repeatable and phantom reads are prevented.
36+
- Note: If the user role selected is SYSDBA or SYSOPER, the plugin will default to TRANSACTION_READ_COMMITTED to prevent ORA-08178 errors
37+
3338
**Connection Type** Whether to use an SID or Service Name when connecting to the database.
3439

3540
**SID/Service Name/TNS Connect Descriptor:** Oracle connection point (Database name, Service name, or a TNS Connect Descriptor). When using TNS, place

oracle-plugin/docs/Oracle-batchsource.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ the full TNS Connect Descriptor in the text field. For example:
3838

3939
**Role** Login role of the user when connecting to the database.
4040

41+
**Transaction Isolation Level** The transaction isolation level of the databse connection
42+
- TRANSACTION_READ_COMMITTED: No dirty reads. Non-repeatable reads and phantom reads are possible.
43+
- TRANSACTION_SERIALIZABLE (default): No dirty reads. Non-repeatable and phantom reads are prevented.
44+
- Note: If the user role selected is SYSDBA or SYSOPER, the plugin will default to TRANSACTION_READ_COMMITTED to prevent ORA-08178 errors
45+
4146
**Import Query:** The SELECT query to use to import data from the specified table.
4247
You can specify an arbitrary number of columns to import, or import all columns using \*. The Query should
4348
contain the '$CONDITIONS' string. For example, 'SELECT * FROM table WHERE $CONDITIONS'.

oracle-plugin/docs/Oracle-connector.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ the full TNS Connect Descriptor in the text field. For example:
3131

3232
**Role:** Login role of the user when connecting to the database.
3333

34+
**Transaction Isolation Level** The transaction isolation level of the databse connection
35+
- TRANSACTION_READ_COMMITTED: No dirty reads. Non-repeatable reads and phantom reads are possible.
36+
- TRANSACTION_SERIALIZABLE (default): No dirty reads. Non-repeatable and phantom reads are prevented.
37+
- Note: If the user role selected is SYSDBA or SYSOPER, the plugin will default to TRANSACTION_READ_COMMITTED to prevent ORA-08178 errors
38+
3439
**Connection Arguments:** A list of arbitrary string tag/value pairs as connection arguments. These arguments
3540
will be passed to the JDBC driver, as connection arguments, for JDBC drivers that may need additional configurations.
3641
This is a semicolon-separated list of key-value pairs, where each pair is separated by a equals '=' and specifies

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnectorConfig.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ public String getConnectionString() {
7979
@Macro
8080
private String database;
8181

82+
@Name(OracleConstants.TRANSACTION_ISOLATION_LEVEL)
83+
@Description("The transaction isolation level for the database session.")
84+
@Macro
85+
@Nullable
86+
private String transactionIsolationLevel;
87+
8288
@Override
8389
protected int getDefaultPort() {
8490
return 1521;
@@ -105,10 +111,17 @@ public Properties getConnectionArgumentsProperties() {
105111
prop.put(INTERNAL_LOGON_PROPERTY, getRole());
106112
return prop;
107113
}
108-
114+
109115
public String getTransactionIsolationLevel() {
110-
return ROLE_NORMAL.equals(getRole()) ? null :
111-
TransactionIsolationLevel.Level.TRANSACTION_READ_COMMITTED.name();
116+
//if null default to the highest isolation level possible
117+
if (transactionIsolationLevel == null) {
118+
transactionIsolationLevel = TransactionIsolationLevel.Level.TRANSACTION_SERIALIZABLE.name();
119+
}
120+
//To solve the problem of ORA-08178: illegal SERIALIZABLE clause specified for user INTERNAL
121+
//This ensures that the role is mapped to the right serialization level, even w/ incorrect user input
122+
//if role is SYSDBA or SYSOP it will map to read_committed. else serialized
123+
return (!getRole().equals(ROLE_NORMAL)) ? TransactionIsolationLevel.Level.TRANSACTION_READ_COMMITTED.name() :
124+
TransactionIsolationLevel.Level.valueOf(transactionIsolationLevel).name();
112125
}
113126

114127
@Override

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ private OracleConstants() {
3535
public static final String ROLE = "role";
3636
public static final String NAME_DATABASE = "database";
3737
public static final String TNS_CONNECTION_TYPE = "TNS";
38+
public static final String TRANSACTION_ISOLATION_LEVEL = "transactionIsolationLevel";
3839
}

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public static class OracleSourceConfig extends AbstractDBSpecificSourceConfig {
7878
@Nullable
7979
@Description("Whether to use an existing connection.")
8080
private Boolean useConnection;
81+
8182
@Name(NAME_CONNECTION)
8283
@Macro
8384
@Nullable
@@ -130,7 +131,7 @@ public void validate(FailureCollector collector) {
130131

131132
@Override
132133
public String getTransactionIsolationLevel() {
133-
return getConnection().getTransactionIsolationLevel();
134+
return connection.getTransactionIsolationLevel();
134135
}
135136
}
136137

oracle-plugin/widgets/Oracle-batchsink.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@
8888
]
8989
}
9090
},
91+
{
92+
"widget-type": "select",
93+
"label": "Transaction Isolation Level",
94+
"name": "transactionIsolationLevel",
95+
"widget-attributes": {
96+
"values": [
97+
"TRANSACTION_READ_COMMITTED",
98+
"TRANSACTION_SERIALIZABLE"
99+
],
100+
"default": "TRANSACTION_SERIALIZABLE"
101+
}
102+
},
91103
{
92104
"name": "connectionType",
93105
"label": "Connection Type",
@@ -179,6 +191,18 @@
179191
],
180192
"outputs": [],
181193
"filters": [
194+
{
195+
"name": "showIsolationLevels",
196+
"condition": {
197+
"expression": "role == 'normal'"
198+
},
199+
"show": [
200+
{
201+
"type": "property",
202+
"name": "transactionIsolationLevel"
203+
}
204+
]
205+
},
182206
{
183207
"name": "showConnectionProperties ",
184208
"condition": {
@@ -220,6 +244,10 @@
220244
{
221245
"type": "property",
222246
"name": "database"
247+
},
248+
{
249+
"type": "property",
250+
"name": "transactionIsolationLevel"
223251
}
224252
]
225253
},

oracle-plugin/widgets/Oracle-batchsource.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@
8888
]
8989
}
9090
},
91+
{
92+
"widget-type": "select",
93+
"label": "Transaction Isolation Level",
94+
"name": "transactionIsolationLevel",
95+
"widget-attributes": {
96+
"values": [
97+
"TRANSACTION_READ_COMMITTED",
98+
"TRANSACTION_SERIALIZABLE"
99+
],
100+
"default": "TRANSACTION_SERIALIZABLE"
101+
}
102+
},
91103
{
92104
"name": "connectionType",
93105
"label": "Connection Type",
@@ -237,6 +249,18 @@
237249
}
238250
],
239251
"filters": [
252+
{
253+
"name": "showIsolationLevels",
254+
"condition": {
255+
"expression": "role == 'normal'"
256+
},
257+
"show": [
258+
{
259+
"type": "property",
260+
"name": "transactionIsolationLevel"
261+
}
262+
]
263+
},
240264
{
241265
"name": "showConnectionProperties ",
242266
"condition": {
@@ -278,6 +302,10 @@
278302
{
279303
"type": "property",
280304
"name": "database"
305+
},
306+
{
307+
"type": "property",
308+
"name": "transactionIsolationLevel"
281309
}
282310
]
283311
},

oracle-plugin/widgets/Oracle-connector.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@
9797
}
9898
]
9999
}
100+
},
101+
{
102+
"widget-type": "select",
103+
"label": "Transaction Isolation Level",
104+
"name": "transactionIsolationLevel",
105+
"widget-attributes": {
106+
"values": [
107+
"TRANSACTION_READ_COMMITTED",
108+
"TRANSACTION_SERIALIZABLE"
109+
],
110+
"default": "TRANSACTION_SERIALIZABLE"
111+
}
100112
}
101113
]
102114
},
@@ -118,5 +130,19 @@
118130
]
119131
}
120132
],
133+
"filters" : [
134+
{
135+
"name": "showIsolationLevels",
136+
"condition": {
137+
"expression": "role == 'normal'"
138+
},
139+
"show": [
140+
{
141+
"type": "property",
142+
"name": "transactionIsolationLevel"
143+
}
144+
]
145+
}
146+
],
121147
"outputs": []
122148
}

0 commit comments

Comments
 (0)