Skip to content

Conversation

@maheshk114
Copy link
Contributor

The transactions opened by applying EVENT_OPEN_TXN should never be aborted automatically due to time-out. Aborting of transaction started by replication task may leads to inconsistent state at target which needs additional overhead to clean-up. So, it is proposed to mark the transactions opened by replication task as special ones and shouldn't be aborted if heart beat is lost. This helps to ensure all ABORT and COMMIT events will always find the corresponding txn at target to operate.

enum TxnStatus {OPEN, ABORTED, COMMITTED, UNKNOWN}

public enum TxnType {
REPL_CREATED(0), READ_ONLY(1), UNKNOWN(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall use DEFAULT instead of UNKNOWN as it seems like invalid type. Also, value "0" can be default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unknown is just a place holder ..default is null

Copy link
Contributor

Choose a reason for hiding this comment

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

For TxnState, UNKNOWN is used to specify an invalid state of txn. So, thought it would make sense to use something else to mean Read-Write non-REPL created txns instead of UNKNOWN.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

need change

" TXN_STARTED bigint NOT NULL," +
" TXN_LAST_HEARTBEAT bigint NOT NULL," +
" TXN_USER varchar(128) NOT NULL," +
" TXN_TYPE integer," +
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use single char instead of integer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure how different databases behaves for char type ..int looks quite standard so used it.

Copy link
Contributor

Choose a reason for hiding this comment

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

TXN_STATE column uses character only... :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

integer is fine

this.value = value;
}

public int getValue() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't by default integer values assigned to each enum member? Shall we use it instead of explicit assignment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is some conversion error to int from enum ..other places also it is used like this

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

" TXN_STARTED bigint NOT NULL," +
" TXN_LAST_HEARTBEAT bigint NOT NULL," +
" TXN_USER varchar(128) NOT NULL," +
" TXN_TYPE integer," +
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add it as last column to keep same as upgrade flow with ADD COLUMN?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can not predict the internal behavior of dbms related to column order ..so it should not be an issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok

TXN_META_INFO varchar(128),
TXN_HEARTBEAT_COUNT integer
TXN_HEARTBEAT_COUNT integer,
TXN_TYPE integer
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be NOT NULL column.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

need not be not null ..as user can skip it if its not required. We don't need this value for all kind of transactions.

Copy link
Contributor

Choose a reason for hiding this comment

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

How user will skip it? It is internal metadata set by Hive itself to identify the type of txn. As I see in code, it is set as REPL_CREATED for repl txns and UNKNOWN if not which means it is set in all flow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

keeping it null wont impact anything


CREATE INDEX IDX_RUNTIME_STATS_CREATE_TIME ON RUNTIME_STATS(CREATE_TIME);

ALTER TABLE TXNS ADD COLUMN TXN_TYPE integer;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall initialize with 0 for existing entries in TXNS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think txns does not span across upgrades ..anyways default is null

rqst.getReplPolicy() + " and Source transaction id : " + rqst.getReplSrcTxnIds().toString());
return new OpenTxnsResponse(targetTxnIdList);
}
txnType = TxnType.REPL_CREATED;
Copy link
Contributor

Choose a reason for hiding this comment

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

Need rebasing with master.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

numOpen++;
}
}
assertEquals(3, numAborted);
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this be flaky if run the whole suit as the number of aborted/open txns cannot be guaranteed to be 0 when start test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

previous test cases also have same issues ..looks like it creates a new txn handler ..so should not be an issue

Copy link
Contributor

Choose a reason for hiding this comment

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

ok


CREATE INDEX IDX_RUNTIME_STATS_CREATE_TIME ON RUNTIME_STATS(CREATE_TIME);

ALTER TABLE TXNS ADD TXN_TYPE int;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to have -- HIVE-19340 comment for changes done part of this ticket. Shall have it in all upgrade scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@maheshk114 maheshk114 force-pushed the BUG-92700 branch 4 times, most recently from cc3af33 to 0f35298 Compare May 24, 2018 17:12
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the dev@hive.apache.org list if the patch is in need of reviews.

@github-actions github-actions bot added the stale label Jun 16, 2020
@github-actions github-actions bot closed this Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants