kafka-connect-jdbc-sink icon indicating copy to clipboard operation
kafka-connect-jdbc-sink copied to clipboard

Consider handling different transaction isolation levels

Open iamgollum opened this issue 5 years ago • 0 comments

Observation

Relational DBMS use transaction to preserve data integrity. To avoid conflicts during a transaction, the db locks, mechanisms for blocking access by others to the data that is being accessed by the transaction. (Note that in auto-commit mode, where each statement is a transaction, locks are held for only one statement.) After a lock is set, it remains in force until the transaction is committed or rolled back. For example, a DBMS could lock a row of a table until updates to it have been committed. The effect of this lock would be to prevent a user from getting a dirty read, that is, reading a value before it is made permanent. (Accessing an updated value that has not been committed is considered a dirty read because it is possible for that value to be rolled back to its previous value. If you read a value that is later rolled back, you will have read an invalid value.)

How locks are set is determined by what is called a transaction isolation level, which can range from not supporting transactions at all to supporting transactions that enforce very strict access rules.

JDBC Isolation Levels

Screen Shot 2020-04-21 at 9 41 43 AM

A JDBC driver might not support all transaction isolation levels. If a driver does not support the isolation level specified in an invocation of setTransactionIsolation, the driver can substitute a higher, more restrictive transaction isolation level. If a driver cannot substitute a higher transaction level, it throws a SQLException. Use the method DatabaseMetaData.supportsTransactionIsolationLevel to determine whether or not the driver supports a given level.

Action Item

Handle different transaction levels according to driver support

iamgollum avatar Apr 21 '20 13:04 iamgollum