Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes transaction handling within changesets on DB2 on z/OS #3342

Merged
merged 11 commits into from
Nov 18, 2022

Conversation

MichaelKern-IVV
Copy link
Contributor

@MichaelKern-IVV MichaelKern-IVV commented Oct 5, 2022

Impact

  • Bug fix (non-breaking change which fixes expected existing functionality)
  • Enhancement/New feature (adds functionality without impacting existing logic)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Erroneous ChangeSets are not always completely rolled back.

Fixes #3299

This is the case because unnecessary and therefore erroneous commits are performed under DB2z. And because liquibase does not honor that DB2z supports DDL in transactions.

Things to be aware of

I executed a test script:

`DB2 => connect to db2eha user a61kern
Aktuelles Kennwort für a61kern eingeben:

Datenbankverbindungsinformationen

Datenbank-Server = DB2 z/OS 12.1.5
SQL-Berechtigungs-ID = A61KERN
Aliasname der lokalen Datenbank = DB2EHA

DB2 => create table test1 (id integer not null primary key, name varchar(20))
DB20000I Der Befehl SQL wurde erfolgreich ausgeführt.
DB2 =>
DB2 => comment on table test1 is 'Table for auto commit test'
DB20000I Der Befehl SQL wurde erfolgreich ausgeführt.
DB2 =>
DB2 => insert into test1 values (1, 'Test 1')
DB20000I Der Befehl SQL wurde erfolgreich ausgeführt.
DB2 =>
DB2 => select * from test1

ID NAME


      1 Test 1 

1 Satz/Sätze ausgewählt.

DB2 =>
DB2 => commit
DB20000I Der Befehl SQL wurde erfolgreich ausgeführt.
DB2 =>
DB2 => create table test2 (id integer not null primary key, name varchar(20))
DB20000I Der Befehl SQL wurde erfolgreich ausgeführt.
DB2 =>
DB2 => comment on table test2 is 'Another Table for auto commit test'
DB20000I Der Befehl SQL wurde erfolgreich ausgeführt.
DB2 =>
DB2 => insert into test2 values (1, 'Test 2')
DB20000I Der Befehl SQL wurde erfolgreich ausgeführt.
DB2 =>
DB2 => select * from test2

ID NAME


      1 Test 2 

1 Satz/Sätze ausgewählt.

DB2 =>
DB2 => rollback
DB20000I Der Befehl SQL wurde erfolgreich ausgeführt.
DB2 =>
DB2 => select * from test1

ID NAME


      1 Test 1 

1 Satz/Sätze ausgewählt.

DB2 =>
DB2 => select * from test2
SQL0204N "A61KERN.TEST2" ist ein nicht definierter Name. SQLSTATE=42704
DB2 =>
DB2 => connect reset
DB20000I Der Befehl SQL wurde erfolgreich ausgeführt.
DB2 =>
`

It can be observed from the outputs that

  1. DDL statements are subject to the transaction control and can be rolled back
  2. created objects can be used immediately and within the same transaction

Things to worry about

I only have access to a DB2z 12 and cannot verify for older versions if the behavior is the same.

All the people I have talked to, especially the DB2z administrators in the company, have claimed that the behavior has always been like this and has never been modified.

public Db2zDatabase() {

Db2zDatabase() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove the public from this? I think that will keep this extension from being loaded by the ServiceLoader, because it needs a public no-arg constuctor.

@nvoxland
Copy link
Contributor

nvoxland commented Oct 5, 2022

Thanks for the follow-up on the transaction logic on db2/z, @MichaelKern-IVV.

Unrelated question but while I have you: is the CURRENT TIMESTAMP function the correct one for getting the current time on db2/z? Is that something that varies between versions? I've maybe seen some issues since we recently changed that, but I've not gotten a chance to follow through with them yet.

@nvoxland nvoxland self-assigned this Oct 5, 2022
@nvoxland nvoxland changed the title Issue/3299 Fixes transaction handling within changesets on DB2 on z/OS Oct 6, 2022
@MichaelKern-IVV
Copy link
Contributor Author

@nvoxland I have now removed the Db2zDatabase construtor completely since it only made the same settings as AbstractDb2Database.

@MichaelKern-IVV
Copy link
Contributor Author

@nvoxland There are three "special registers" to obtain time information:

`DB2 => select current time t, current date d, current timestamp ts from sysibm.sysdummy1

T D TS


10.08.24 2022-10-07 2022-10-07-10.08.24.144289

1 Satz/Sätze ausgewählt.`

As far as I remember (and as long as the IBM documentation goes back) this has always been the case and has never changed.

In short I think CURRENT TIMESTAMP is the correct one.

@nvoxland nvoxland added the SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions label Oct 7, 2022
@nvoxland
Copy link
Contributor

nvoxland commented Oct 7, 2022

Thanks for the info and thanks for the extra commits, @MichaelKern-IVV .

Copy link
Contributor

@nvoxland nvoxland left a comment

Choose a reason for hiding this comment

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

Code review and test results:

Things to be aware of:

  • Only impacts db2 on z

Things to worry about:

  • Nothing, contributor answered the questions I had

@github-actions
Copy link

github-actions bot commented Oct 7, 2022

Unit Test Results

  4 668 files  ±0    4 668 suites  ±0   34m 5s ⏱️ +27s
  4 645 tests ±0    4 419 ✔️ ±0     226 💤 ±0  0 ±0 
54 744 runs  ±0  49 625 ✔️ ±0  5 119 💤 ±0  0 ±0 

Results for commit 7e7eeef. ± Comparison against base commit 0f1cb97.

♻️ This comment has been updated with latest results.

@nvoxland nvoxland removed their assignment Oct 11, 2022
@XDelphiGrl
Copy link
Contributor

@filipelautert, hello! I'm moving this ticket back to Development as the PR is not building for some reason. I'll keep an eye out to see when this comes back to code review. Thanks!

@filipelautert filipelautert removed the SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions label Nov 4, 2022
@filipelautert filipelautert self-assigned this Nov 4, 2022
@filipelautert filipelautert added the SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions label Nov 4, 2022
@filipelautert filipelautert self-requested a review November 4, 2022 23:39
@filipelautert
Copy link
Collaborator

Hi @XDelphiGrl - now it is building fine :)

Copy link
Contributor

@XDelphiGrl XDelphiGrl left a comment

Choose a reason for hiding this comment

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

With this PR, Liquibase now honors DDL transactions for the DB2/Z database.

  • No additional testing required.

APPROVED

@filipelautert filipelautert added SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions and removed SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions labels Nov 18, 2022
@filipelautert filipelautert merged commit cae3297 into liquibase:master Nov 18, 2022
@MichaelKern-IVV MichaelKern-IVV deleted the issue/3299 branch November 23, 2022 09:06
@filipelautert filipelautert added this to the 4.18.0 milestone Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autocandidate SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

ChangeSet is not rolled back completely in case of an error for Db2z
6 participants