Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

[TRAFODION-3280] Reduce path length in Trafodion for improved performance and scalability #1824

Merged
merged 10 commits into from Apr 8, 2019

Conversation

selvaganesang
Copy link
Contributor

Removed/avoided the following APIs shown as hotspots when Trafodion is run with OLTP kind of queries.

java.net.Socket.setSoTimeout
org.trafodion.jdbc.t4.T4LoggingUtilities.log
java.net.Socket.getLocalSocketAddress
java.lang.String.split
java.lang.String.replaceAll
java.lang.Class.getMethod
org.trafodion.jdbc.t4.TrafT4ResultSet.findColumn

Now socket.read waits for the network timeout. It can be configured via a property networkTimeout or call to connection.setNetworkTimeout. If the networkTimeout is not configured, a default value of 10 secs is assumed.

The caller is expected to set the timeout depending upon the operation being performed like loginTimeout, queryTimeout. Socket.read will wake up for every networkTimeout expiration and check if the timeout for the operation hasn't exceeded. When it exceeds, SocketTimeoutException is thrown.

Changed the T4Statement and T4Restult classes to have "has a" relationship with T4Connection for better understanding of the code. Earlier, it had "is a" relationship with T4Connection.

JDBC driver was parsing the sql string passed to it by the application to determine the type of SQL statement and to check if the sql string has parameters. It doesn't parse the sql string anymore
and passes the sql string to SQL engine via mxosrvr. In case of PreparedStatement, the JDBC driver will
set the sqlStmtType based on the query type returned. In case of Statement, the JDBC driver will set the
sqlStmtType as SQL_TYPE_UNKNOWN.

Now, the PreparedStatement is always prepared for setting array values for parameter for all
statement types such as IUD and select. SQL engine will report an error if the array values are
not supported for any statement type.

Changed Hashtable to HashMap where possible with the assumption that the JDBC connection
shouldn't be used from different threads. TrafT4Connection object needs be made thread-safe.

Optimized org.trafodion.jdbc.t4.TrafT4ResultSet.findColumn by using HashMap of columnName to
columnIndex. This should avoid excessive calls to java.lang.String.equalsIgnoreCase.

Removed excessive calls to java.lang.Class.getMethod from TrafT4ResultSet.

When the statement type is TYPE_UNKNOWN, mxosrvr was executing the extra code
to load controls, GetHashInfo etc. GetHashInfo was corrupting the sqlString by
truncating spaces in between the literals. Removed these code from mxosrvr because it is specific to QueryStatsServer as part of NeoView and WMS.

There are many places in our code getenv is called repeatedly. Cleaned up code so that
repeated getenv calls are avoided during prepare and execute operations.

… in jprofile

java.net.Socket.setSoTimeout
org.trafodion.jdbc.t4.T4LoggingUtilities.log
java.net.Socket.getLocalSocketAddress

Now socket.read waits for the network timeout. It can be configured via a property networkTimeout or
call to connection.setNetworkTimeout. If the networkTimeout is not configured, a default value of 10 secs
is assumed.

The caller is expected to set the timeout depending upon the operation being performed like loginTimeout,
queryTimeout. Socket.read will wake up for every networkTimeout expiration and check if the timeout for the
operation hasn't exceeded. When it exceeds, SocketTimeoutException is thrown.

Changed the T4Statement and T4Restult classes to have "has a" relationship with T4Connection for
better understanding of the code. Earlier, it had "is a" relationship with T4Connection.
… in jprofile - part-II

java.lang.String.split and javal.lang.String.replaceAll

JDBC driver was parsing the sql string passed to it by the application to determine the type of
SQL statement and to check if the sql string has parameters. It doesn't parse the sql string anymore
and passes the sql string to SQL engine via mxosrvr. In case of PreparedStatement, the JDBC driver will
set the sqlStmtType based on the query type returned. In case of Statement, the JDBC driver will set the
sqlStmtType as SQL_TYPE_UNKNOWN.

Now, the PreparedStatement is always prepared for setting array values for parameter for all
statement types such as IUD and select. SQL engine will report an error if the array values are
not supported for any statement type.
via Connection.commit and Connection.rollback. The transaction is always
started by the database engine when it needs the transaction.

However, begin work and commit work is still supported via SQL command but
there is no transaction state is maintained in the driver for these commands.
… in jprofile - part-II

Changed Hashtable to HashMap where possible with the assumption that the JDBC connection
shouldn't be used from different threads. TrafT4Connection object needs be made thread-safe.

Optimized org.trafodion.jdbc.t4.TrafT4ResultSet.findColumn by using HashMap of columnName to
columnIndex. This should avoid excessive calls to java.lang.String.equalsIgnoreCase.

Removed excessive calls to java.lang.Class.getMethod from TrafT4ResultSet
… in jprofile - part-IIa

Removed ununsed code
…ecent sql

command instead of returning "--- SQL operation complete" always.
…rimFunction

of VariableLengthPKTest in phoenix T4 tests.

When the statement type is TYPE_UNKNOWN, mxosrvr was executing the extra code
to load controls, GetHashInfo etc. GetHashInfo was corrupting the sqlString by
truncating spaces in between the literals.

Removed these code from mxosrvr because it is specific to QueryStatsServer as part of
NeoView and WMS.
FunkyNamesTest has been removed temporarily
EsgynDB is not able to support delimited column names correctly. It has always been returning incorrect results.
We have modified FunkyNamesTest to suit our behavior. With the change to move from Array to HashMap for performance
reasons in both T4 and T2 driver code. However, the incorrect results differ between T2 and T4 when there are
more than one delimited column name matches due to uppercasing the column name always.  This needs some change
in the descriptor information sent from SQL engine to denote that column names are delimited to preserve case.
We need to use the case preserving key String for delimited column names and case insensitive key String for
regular column names in the HashMap to convert from column names to column index.
…ance and scalability

There are many places in Trafodion code getenv is called repeatedly. Cleaned up code so that
repeated getenv calls are avoided during prepare and execute operations.
@Traf-Jenkins
Copy link

Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/3184/

@Traf-Jenkins
Copy link

@@ -1228,20 +1111,13 @@ void prepare(String sql, int queryTimeout, TrafT4PreparedStatement pstmt) throws
// txId = Bytes.createIntBytes(0, false);
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 delete the commented line

@@ -5492,10 +5492,12 @@ SQLRETURN SRVR::PREPARE2withRowsets(SRVR_STMT_HDL* pSrvrStmt)
HANDLE_ERROR(retcode, sqlWarning);

if (pSrvrStmt->maxRowsetSize > 1
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

remove the comment section

if (pSrvrStmt->maxRowsetSize > 1
&& (pSrvrStmt->sqlStmtType == TYPE_INSERT_PARAM))
if (pSrvrStmt->maxRowsetSize > 1)
// && (pSrvrStmt->sqlStmtType == TYPE_INSERT_PARAM))
Copy link
Contributor

Choose a reason for hiding this comment

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

same here. delete commented lines

Copy link
Contributor

@hegdean hegdean left a comment

Choose a reason for hiding this comment

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

Change looks good to me. Thanks Selva

@selvaganesang selvaganesang merged commit 869fbde into apache:master Apr 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants