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

Use Socket instead of SocketChannel when multiSubnetFailover=true #662

Merged
merged 1 commit into from
Apr 5, 2018

Conversation

ulvii
Copy link
Contributor

@ulvii ulvii commented Mar 20, 2018

Fix for both #144 and #645 .This PR reverts #160.

Switching from SocketChannels to Sockets to avoid creating 2 connections when multiSubnetFailover=true.

@codecov-io
Copy link

codecov-io commented Mar 20, 2018

Codecov Report

Merging #662 into dev will increase coverage by 0.28%.
The diff coverage is 62.5%.

Impacted file tree graph

@@             Coverage Diff              @@
##                dev     #662      +/-   ##
============================================
+ Coverage     48.08%   48.37%   +0.28%     
- Complexity     2575     2593      +18     
============================================
  Files           113      113              
  Lines         26574    26574              
  Branches       4429     4430       +1     
============================================
+ Hits          12778    12854      +76     
- Misses        11665    11674       +9     
+ Partials       2131     2046      -85
Flag Coverage Δ Complexity Δ
#JDBC42 48.24% <62.5%> (+0.27%) 2589 <0> (+19) ⬆️
#JDBC43 47.92% <62.5%> (-0.1%) 2563 <0> (-9)
Impacted Files Coverage Δ Complexity Δ
...in/java/com/microsoft/sqlserver/jdbc/IOBuffer.java 56.42% <62.5%> (+2.29%) 0 <0> (ø) ⬇️
...rc/main/java/com/microsoft/sqlserver/jdbc/DDC.java 44.74% <0%> (-0.45%) 106% <0%> (-1%)
...m/microsoft/sqlserver/jdbc/SQLServerResultSet.java 32.73% <0%> (-0.29%) 241% <0%> (-3%)
...om/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java 52.54% <0%> (-0.13%) 239% <0%> (-2%)
...rc/main/java/com/microsoft/sqlserver/jdbc/dtv.java 63.05% <0%> (-0.13%) 0% <0%> (ø)
...om/microsoft/sqlserver/jdbc/ReaderInputStream.java 44.94% <0%> (ø) 16% <0%> (ø) ⬇️
...m/microsoft/sqlserver/jdbc/SQLServerException.java 77.23% <0%> (ø) 31% <0%> (+1%) ⬆️
...c/main/java/com/microsoft/sqlserver/jdbc/Util.java 61.57% <0%> (ø) 91% <0%> (+2%) ⬆️
...ncurrentlinkedhashmap/ConcurrentLinkedHashMap.java 38.75% <0%> (+0.21%) 42% <0%> (ø) ⬇️
...m/microsoft/sqlserver/jdbc/SQLServerStatement.java 59.81% <0%> (+0.3%) 137% <0%> (+6%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3a8c146...a821e1f. Read the comment docs.

@ulvii
Copy link
Contributor Author

ulvii commented Mar 20, 2018

Hi @greg-pendlebury and @sehrope,

We would very much appreciate if you could test the attached jars against #144 and #645.

@greg-pendlebury
Copy link

Thanks @ulvii, one of our DBAs tested the jar with JMeter using the same test we used in demonstrating #645. He has confirmed that the NUMA affinity issues are resolved. We will try updating our full application once a release of the driver is available, but the regression testing of all the other changes since 6.1.7 might take us some time.

@sehrope
Copy link
Contributor

sehrope commented Mar 21, 2018

Sure we'll get this tested. Are the jars you've attached built off the tip of this PR? i.e. can I just build the PR?

I took a peek at the diff itself and it's quite minimal. The main change seems to be replacing findSocketUsingJavaNIO(...) with findSocketUsingThreading(...) which has existed at least since the open sourcing of the driver but doesn't seem to have been referenced in any active code.

@ulvii
Copy link
Contributor Author

ulvii commented Mar 21, 2018

Thanks @greg-pendlebury , @sehrope .

@sehrope , yes the jars are built on top of the PR.

@sehrope
Copy link
Contributor

sehrope commented Mar 21, 2018

We tested this a bit and it doesn't break query cancellation when multiSubnetFailover is enabled.

I think it'd be worthwhile to eventually rewrite how SocketFinder is implemented. The concept itself is fine, i.e use a thread pool to race opening sockets to all resolved addresses. The complexity is that it's done using manual locking, .wait(...), .notify() and the code is intermixed with the parent class. It likely predates modern concurrency primitives and redoing it using something like Future or CountDownLatch would simplify things.

The current code also handles IPv4 and IPv6 sequentially. I don't see that behavior explicitly documented anywhere nor does it seem like it'd be useful. If a user has multiple address types resolving from a host name they should all be attempted in parallel right? I took a stab at a high level clean up for this. See here for a PR: #663

@cheenamalhotra cheenamalhotra added this to the 6.5.1 milestone Mar 23, 2018
@ulvii ulvii merged commit 07e391e into microsoft:dev Apr 5, 2018
rene-ye pushed a commit to rene-ye/mssql-jdbc that referenced this pull request Apr 6, 2018
rene-ye added a commit that referenced this pull request Apr 6, 2018
* Added more information to error messages

To help debug an irreproducable/random mismatch error if it occurs in the future.

* Fix for the issue when using setMaxRows() with SHOWPLAN ON (#666)

* Dont throw exception for colmetadata token

* Adding a comment

* Update comment

* Adding a warning message

* remove ignoreLengthPrefixedToken

* Fix for uncaught/unhandled exception (#664)

* Added more information to error messages

To help debug an irreproducable/random mismatch error if it occurs in the future.

* Revert "Added information to error message"

This reverts commit 25301e6.

* Fix for #659

Added error handling logic for special cases.

* Read message length

Read the message length instead of reading until terminating character

* Unsigned byte update

Message length is an unsigned byte, converting before using.

* Removed clunky hex conversions

convert the byte straight to an int and use existing constants instead of making new ones

* Narrowed trigger conditions

fixed an issue where column names who had the hex token 'AA' would cause an error to be thrown.

* Spacing fixes

* Added test case

* spacing adjustment

* Edited test drop procedures

Changed IF EXISTS DROP commands to be compatible with sql server 2008

* github spacing misalignment fixes

* Changed test condition

now only runs on compatible database or higher

* Removed error check

Removed a previous implementation in favor of one that changes the TDS parser

* tdsreader change

* removing test for now

* enabled tests

* github spacing fix

* removed array import

* removed "arrays" instead of "array"

* spacing changes

* Use Socket instead of SocketChannel when multiSubnetFailover=true (#662)

* Upped SQL Server requirement to 2017

* Removing Exception Test

Implement a more generic and compatible test in the future

* Removed imports

Used in removed test
cheenamalhotra pushed a commit that referenced this pull request Apr 6, 2018
* Added more information to error messages

To help debug an irreproducable/random mismatch error if it occurs in the future.

* Fix for the issue when using setMaxRows() with SHOWPLAN ON (#666)

* Dont throw exception for colmetadata token

* Adding a comment

* Update comment

* Adding a warning message

* remove ignoreLengthPrefixedToken

* Fix for uncaught/unhandled exception (#664)

* Added more information to error messages

To help debug an irreproducable/random mismatch error if it occurs in the future.

* Revert "Added information to error message"

This reverts commit 25301e6.

* Fix for #659

Added error handling logic for special cases.

* Read message length

Read the message length instead of reading until terminating character

* Unsigned byte update

Message length is an unsigned byte, converting before using.

* Removed clunky hex conversions

convert the byte straight to an int and use existing constants instead of making new ones

* Narrowed trigger conditions

fixed an issue where column names who had the hex token 'AA' would cause an error to be thrown.

* Spacing fixes

* Added test case

* spacing adjustment

* Edited test drop procedures

Changed IF EXISTS DROP commands to be compatible with sql server 2008

* github spacing misalignment fixes

* Changed test condition

now only runs on compatible database or higher

* Removed error check

Removed a previous implementation in favor of one that changes the TDS parser

* tdsreader change

* removing test for now

* enabled tests

* github spacing fix

* removed array import

* removed "arrays" instead of "array"

* spacing changes

* Use Socket instead of SocketChannel when multiSubnetFailover=true (#662)

* Upped SQL Server requirement to 2017

* Removing Exception Test

Implement a more generic and compatible test in the future

* Removed imports

Used in removed test

* Change in preperation for 6.5.1 preview release

* Removed SNAPSHOT from POM

* Added missing link

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants