Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1059391%22%20slang%3D%22en-US%22%3ESQL%202019%20PolyBase%20Error%3A%20TCP%20Provider%3A%20An%20existing%20connection%20was%20forcibly%20closed%20by%20the%20remote%20host%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1059391%22%20slang%3D%22en-US%22%3E%3CP%3E%3CFONT%20size%3D%223%22%3EIn%20this%20blog%20we%20are%20sharing%20an%20issue%20which%20can%20be%20seen%20while%20querying%20external%20table%20created%20in%20SQL%202019%20with%20data%20source%20pointing%20to%20SQL%20Server%202014.%20The%20error%20message%20which%20comes%20back%20is%20%E2%80%9CTCP%20Provider%3A%20An%20existing%20connection%20was%20forcibly%20closed%20by%20the%20remote%20host%E2%80%9D%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3EWhile%20working%20with%20PolyBase%20feature%2C%20few%20of%20our%20customer%20reported%20an%20interesting%20issue.%20They%20informed%20us%20that%20when%20they%20query%20large%20amount%20of%20data%20by%20creating%20an%20external%20table%20in%20SQL%20Server%202019%20with%20data%20source%20as%20a%20table%20in%20SQL%20Server%202014%2C%20they%20get%20below%20error.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Courier%20New%22%20size%3D%223%22%20color%3D%22%23ff0000%22%3EMsg%207320%2C%20Level%2016%2C%20State%20110%2C%20Line%2082%20%3CBR%20%2F%3E%3CFONT%20face%3D%22Courier%20New%22%20color%3D%22%23ff0000%22%3ECannot%20execute%20the%20query%20%22Remote%20Query%22%20against%20OLE%20DB%20provider%20%22MSOLEDBSQL%22%20for%20linked%20server%20%22(null)%22.%20105082%3BGeneric%20ODBC%20error%3A%20%5BMicrosoft%5D%5BODBC%20Driver%2017%20for%20SQL%20Server%5DTCP%20Provider%3A%20An%20existing%20connection%20was%20forcibly%20closed%20by%20the%20remote%20host.%20%3CBR%20%2F%3E%3CFONT%20face%3D%22Courier%20New%22%20color%3D%22%23ff0000%22%3EAdditional%20error%20%26lt%3B2%26gt%3B%3A%20ErrorMsg%3A%20%5BMicrosoft%5D%5BODBC%20Driver%2017%20for%20SQL%20Server%5DCommunication%20link%20failure%2C%20SqlState%3A%2008S01%2C%20NativeError%3A%2010054.%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CBR%20%2F%3E%3CFONT%20size%3D%223%22%3EThis%20error%20%3CSTRONG%3E%3CU%3Edoesn%E2%80%99t%3C%2FU%3E%3C%2FSTRONG%3E%20appear%20when%3A%20%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%223%22%3EData%20source%20is%20created%20for%20SQL%20Server%20running%202016%20or%20above.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%223%22%3EData%20set%20is%20not%20very%20big.%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3EHere%20are%20the%20steps%20to%20reproduce%20the%20error%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%223%22%3EIn%20SQL%20Server%202014%2C%20create%20a%20login%2C%20create%20a%20database%20and%20then%20table%20inside%20it.%20Insert%20some%20rows.%20(note%20that%20I%20have%20selected%20column%20as%20char(5000)%20so%20that%20we%20fetch%20big%20chunk%20of%20data%20in%20each%20row)%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CBLOCKQUOTE%3E%0A%3CPRE%20class%3D%22code%22%3E%3CFONT%20size%3D%223%22%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EUSE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bmaster%5D%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0ADROP%20LOGIN%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bpolybaselogin%5D%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0ACREATE%20LOGIN%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bpolybaselogin%5D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EWITH%20PASSWORD%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3EN'A_Very_Strong_P%40ssw0rd%40123ForPolyBaseLogin'%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%2C%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EDEFAULT_DATABASE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bmaster%5D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%2C%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EDEFAULT_LANGUAGE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bus_english%5D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%2C%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ECHECK_EXPIRATION%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EOFF%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%2C%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ECHECK_POLICY%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EOFF%0AGO%0A%0AALTER%20SERVER%20ROLE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bsysadmin%5D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EADD%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3EMEMBER%20%5Bpolybaselogin%5D%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FPRE%3E%0A%3CPRE%20class%3D%22code%22%3E%3CFONT%20size%3D%223%22%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ECREATE%20DATABASE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BSQL2014DB%5D%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0AUSE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BSQL2014DB%5D%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0ACREATE%20TABLE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bdbo%5D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E.%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BTable_2014%5D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%0A%20%20%20%20%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bi%5D%20%5Bint%5D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EIDENTITY%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E1%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%2C%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E1%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%20NOT%20NULL%0A%20%20%20%20%2C%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bj%5D%20%5Bchar%5D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E5000%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%20NULL)%20%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0AINSERT%20INTO%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bdbo%5D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E.%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BTable_2014%5D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3Ej%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EVALUES%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E'Microsoft'%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%2C%20(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E'SQL'%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%2C(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E'Server'%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%2C(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E'2019'%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%2C(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E'Released'%3C%2FSPAN%3E%3C%2FFONT%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3CFONT%20size%3D%223%22%3E)%3C%2FFONT%3E%0A%3C%2FSPAN%3E%3C%2FPRE%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%223%22%3ECreate%20external%20table%20in%20SQL%20Server%202019.%20Location%20given%20in%20data%20source%20is%20IP%3APort%20of%20SQL%20Server%202014%20instance.%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CBLOCKQUOTE%3E%0A%3CPRE%20class%3D%22code%22%3E%3CFONT%20size%3D%223%22%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ECREATE%20DATABASE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3ESourceDB%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0AUSE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3ESourceDB%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0ACREATE%20DATABASE%20SCOPED%20CREDENTIAL%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3ESqlServerCredentials%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EWITH%20IDENTITY%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E'polybaselogin'%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%2C%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ESECRET%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E'Sysadmin%40123'%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3B%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0AUSE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3ESourceDB%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0ACREATE%20EXTERNAL%20DATA%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3ESOURCE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3ESQLServer_DestinationDB%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EWITH%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%20%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ELOCATION%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E'sqlserver%3A%2F%2F10.0.0.4%3A21433'%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%2C%0A%20%20%20%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ECREDENTIAL%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3ESQLServerCredentials%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%3B%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0A%0ACREATE%20EXTERNAL%20TABLE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3ESourceDB%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E.%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bdbo%5D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E.%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BExternal_Table_SQL2019_DestinationTable%5D%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%0A%20%20%20%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bi%5D%20%5Bint%5D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3ENULL%2C%0A%20%20%20%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bj%5D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3Echar%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E5000%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%20NULL%0A)%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EWITH%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EDATA_SOURCE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BSQLServer_DestinationDB%5D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%2C%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ELOCATION%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3EN'%5BSQL2014DB%5D.%5Bdbo%5D.%5BTable_2014%5D'%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0A%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FPRE%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%223%22%3EAt%20this%20point%20out%20setup%20is%20ready.%20Lets%20reproduce%20the%20behavior%20now.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%223%22%3EIf%20we%20try%20to%20query%203%20rows%20from%20external%20table%2C%20it%20works%20fine.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%223%22%3EIf%20we%20fetch%204%20rows%20then%20it%20fails.%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CBLOCKQUOTE%3E%0A%3CPRE%20class%3D%22code%22%3E%3CFONT%20size%3D%223%22%3E%3CSPAN%20style%3D%22color%3A%20green%3B%22%3E--%20below%20works%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ESELECT%20TOP%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E3%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E*%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EFROM%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BSourceDB%5D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E.%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bdbo%5D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E.%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BExternal_Table_SQL2019_DestinationTable%5D%0A%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20green%3B%22%3E--%20this%20fails%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ESELECT%20TOP%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E4%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E*%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EFROM%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BSourceDB%5D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E.%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bdbo%5D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E.%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BExternal_Table_SQL2019_DestinationTable%5D%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FPRE%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F161032iBB5FE8550224F609%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_2.png%22%20title%3D%22clipboard_image_2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3EThis%20is%20due%20to%20amount%20of%20data%20fetched%20by%20single%20query.%20In%20my%20example%2C%20column%20is%20char(5000)%20and%20each%20row%20is%20very%20wide.%20One%20of%20our%20customer%20reported%20that%20he%20was%20able%20to%20fetch%20up%20to%20877%20rows%20and%20when%20he%20adds%20one%20more%2C%20the%20error%20appears.%20Here%20is%20the%20text%20of%20error%20message.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22courier%20new%2Ccourier%22%20color%3D%22%23FF0000%22%3EMsg%207320%2C%20Level%2016%2C%20State%20110%2C%20Line%208%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20face%3D%22courier%20new%2Ccourier%22%20color%3D%22%23FF0000%22%3ECannot%20execute%20the%20query%20%22Remote%20Query%22%20against%20OLE%20DB%20provider%20%22MSOLEDBSQL%22%20for%20linked%20server%20%22(null)%22.%20105082%3BGeneric%20ODBC%20error%3A%20%5BMicrosoft%5D%5BODBC%20Driver%2017%20for%20SQL%20Server%5DTCP%20Provider%3A%20An%20existing%20connection%20was%20forcibly%20closed%20by%20the%20remote%20host.%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20face%3D%22courier%20new%2Ccourier%22%20color%3D%22%23FF0000%22%3EAdditional%20error%20%26lt%3B2%26gt%3B%3A%20ErrorMsg%3A%20%5BMicrosoft%5D%5BODBC%20Driver%2017%20for%20SQL%20Server%5DCommunication%20link%20failure%2C%20SqlState%3A%2008S01%2C%20NativeError%3A%2010054%20%3C%2FFONT%3E.%3CFONT%20size%3D%223%22%3E%3CBR%20%2F%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3EHere%20is%20the%20workaround%20to%20overcome%20such%20behavior.%20We%20need%20to%20modify%20data%20source%20to%20use%20a%20connection%20option%20%3CSTRONG%3ECONNECTION_OPTIONS%20%3D%20'UseDefaultEncryptionOptions%3Dfalse'%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3EFirst%20I%20needed%20to%20drop%20data%20source%20as%20it%20was%20used%20by%20external%20table.%20Since%20there%20is%20no%20data%20loss%2C%20we%20should%20be%20OK%20to%20drop%20them.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CPRE%20class%3D%22code%22%3E%3CFONT%20size%3D%222%22%3E%3CFONT%20size%3D%223%22%3E%3CSPAN%20style%3D%22color%3A%20green%3B%22%3E--%20drop%20external%20table%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EUSE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BSourceDB%5D%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0ADROP%20EXTERNAL%20TABLE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bdbo%5D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E.%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BExternal_Table_SQL2019_DestinationTable%5D%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20green%3B%22%3E--%20drop%20external%20data%20source%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EUSE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BSourceDB%5D%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0ADROP%20EXTERNAL%20DATA%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3ESOURCE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BSQLServer_DestinationDB%5D%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20green%3B%22%3E--%20create%20external%20data%20source%20with%20UseDefaultEncryptionOptions%3Dfalse%20.%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EUSE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3ESourceDB%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0ACREATE%20EXTERNAL%20DATA%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3ESOURCE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3ESQLServer_DestinationDB%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EWITH%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%20%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ELOCATION%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E'sqlserver%3A%2F%2F10.0.0.4%3A21433'%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%2C%0A%20%20%20%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ECREDENTIAL%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3ESQLServerCredentials%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%2C%0A%20%20%20%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3ECONNECTION_OPTIONS%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E'UseDefaultEncryptionOptions%3Dfalse'%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%3B%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20green%3B%22%3E--%20create%20external%20table%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ECREATE%20EXTERNAL%20TABLE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3ESourceDB%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E.%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bdbo%5D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E.%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BExternal_Table_SQL2019_DestinationTable%5D%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%0A%20%20%20%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bi%5D%20%5Bint%5D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3ENULL%2C%0A%20%20%20%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5Bj%5D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3Echar%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E5000%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%20NULL%0A)%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EWITH%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EDATA_SOURCE%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BSQLServer_DestinationDB%5D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%2C%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3ELOCATION%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E%3D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20red%3B%22%3EN'%5BSQL2014DB%5D.%5Bdbo%5D.%5BTable_2014%5D'%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20gray%3B%22%3E)%0A%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20blue%3B%22%3EGO%0A%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FPRE%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%20Lets%20try%20to%20run%20the%20same%20query.%20Voil%C3%A0!%20It%20works!%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F161031iF679639333A07C7A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_1.png%22%20title%3D%22clipboard_image_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3EHope%20this%20helps!%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3ECheers%2C%20%3CBR%20%2F%3EBalmukund%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1059391%22%20slang%3D%22en-US%22%3E%3CDIV%20id%3D%22container%22%3E%0A%3CDIV%20id%3D%22wrap%22%3E%0A%3CDIV%20id%3D%22content%22%3E%0A%3CDIV%20id%3D%22post-1842%22%3E%0A%3CDIV%3E%0A%3CDIV%20id%3D%221ef14481-6a90-4359-a7fe-0815e7da1db7%22%20class%3D%22postBody%22%20contenteditable%3D%22true%22%3E%0A%3CP%3EIn%20this%20blog%20we%20are%20sharing%20details%20about%20an%20issue%20which%20can%20be%20seen%20while%20querying%20external%20table%20created%20in%20SQL%202019%20with%20data%20source%20pointing%20to%20SQL%20Server%202014.%20The%20error%20message%20which%20comes%20back%20is%20%E2%80%9CTCP%20Provider%3A%20An%20existing%20connection%20was%20forcibly%20closed%20by%20the%20remote%20host%E2%80%9D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F161030iE5DA6DB28F8E5271%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1059391%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPolyBase%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESQL%202019%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Etcp%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E

In this blog we are sharing an issue which can be seen while querying external table created in SQL 2019 with data source pointing to SQL Server 2014. The error message which comes back is “TCP Provider: An existing connection was forcibly closed by the remote host”

While working with PolyBase feature, few of our customer reported an interesting issue. They informed us that when they query large amount of data by creating an external table in SQL Server 2019 with data source as a table in SQL Server 2014, they get below error.

 

Msg 7320, Level 16, State 110, Line 82
Cannot execute the query "Remote Query" against OLE DB provider "MSOLEDBSQL" for linked server "(null)". 105082;Generic ODBC error: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: An existing connection was forcibly closed by the remote host.
Additional error <2>: ErrorMsg: [Microsoft][ODBC Driver 17 for SQL Server]Communication link failure, SqlState: 08S01, NativeError: 10054.


This error doesn’t appear when:

  • Data source is created for SQL Server running 2016 or above.
  • Data set is not very big.

Here are the steps to reproduce the error:

  • In SQL Server 2014, create a login, create a database and then table inside it. Insert some rows. (note that I have selected column as char(5000) so that we fetch big chunk of data in each row)
USE [master]
GO
DROP LOGIN [polybaselogin]
GO
CREATE LOGIN [polybaselogin] WITH PASSWORD = N'A_Very_Strong_P@ssw0rd@123ForPolyBaseLogin',
DEFAULT_DATABASE = [master] ,DEFAULT_LANGUAGE = [us_english] ,CHECK_EXPIRATION = OFF ,CHECK_POLICY = OFF
GO

ALTER SERVER ROLE [sysadmin] ADD MEMBER [polybaselogin]
GO
CREATE DATABASE [SQL2014DB]
GO
USE [SQL2014DB]
GO
CREATE TABLE [dbo].[Table_2014] (
     [i] [int] IDENTITY(1, 1) NOT NULL
    ,[j] [char](5000) NULL) 
GO
INSERT INTO [dbo].[Table_2014] (j)
VALUES('Microsoft'), ('SQL'),('Server'),('2019'),('Released')
  • Create external table in SQL Server 2019. Location given in data source is IP:Port of SQL Server 2014 instance.
CREATE DATABASE SourceDB
GO
USE SourceDB
GO
CREATE DATABASE SCOPED CREDENTIAL SqlServerCredentials
WITH IDENTITY = 'polybaselogin', SECRET = 'Sysadmin@123';
GO
USE SourceDB
GO
CREATE EXTERNAL DATA SOURCE SQLServer_DestinationDB
WITH ( 
LOCATION = 'sqlserver://10.0.0.4:21433',
    CREDENTIAL = SQLServerCredentials
);
GO

CREATE EXTERNAL TABLE SourceDB.[dbo].[External_Table_SQL2019_DestinationTable]
(
    [i] [int] NULL,
    [j] char(5000) NULL
)
WITH (DATA_SOURCE = [SQLServer_DestinationDB],LOCATION = N'[SQL2014DB].[dbo].[Table_2014]')
GO
  • At this point out setup is ready. Lets reproduce the behavior now.
  • If we try to query 3 rows from external table, it works fine.
  • If we fetch 4 rows then it fails.
-- below works
SELECT TOP 3 *
FROM [SourceDB].[dbo].[External_Table_SQL2019_DestinationTable]

-- this fails
SELECT TOP 4 *
FROM [SourceDB].[dbo].[External_Table_SQL2019_DestinationTable]

 

clipboard_image_2.png

This is due to amount of data fetched by single query. In my example, column is char(5000) and each row is very wide. One of our customer reported that he was able to fetch up to 877 rows and when he adds one more, the error appears. Here is the text of error message.

 

Msg 7320, Level 16, State 110, Line 8
Cannot execute the query "Remote Query" against OLE DB provider "MSOLEDBSQL" for linked server "(null)". 105082;Generic ODBC error: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: An existing connection was forcibly closed by the remote host.
Additional error <2>: ErrorMsg: [Microsoft][ODBC Driver 17 for SQL Server]Communication link failure, SqlState: 08S01, NativeError: 10054 .

 

Here is the workaround to overcome such behavior. We need to modify data source to use a connection option CONNECTION_OPTIONS = 'UseDefaultEncryptionOptions=false'

First I needed to drop data source as it was used by external table. Since there is no data loss, we should be OK to drop them.

 

-- drop external table
USE [SourceDB]
GO
DROP EXTERNAL TABLE [dbo].[External_Table_SQL2019_DestinationTable]
GO
-- drop external data source
USE [SourceDB]
GO
DROP EXTERNAL DATA SOURCE [SQLServer_DestinationDB]
GO
-- create external data source with UseDefaultEncryptionOptions=false .
USE SourceDB
GO
CREATE EXTERNAL DATA SOURCE SQLServer_DestinationDB
WITH ( 
LOCATION = 'sqlserver://10.0.0.4:21433',
    CREDENTIAL = SQLServerCredentials,
    CONNECTION_OPTIONS = 'UseDefaultEncryptionOptions=false'
);
GO
-- create external table
CREATE EXTERNAL TABLE SourceDB.[dbo].[External_Table_SQL2019_DestinationTable]
(
    [i] [int] NULL,
    [j] char(5000) NULL
)
WITH (DATA_SOURCE = [SQLServer_DestinationDB],LOCATION = N'[SQL2014DB].[dbo].[Table_2014]')
GO

Lets try to run the same query. Voilà! It works!

 

clipboard_image_1.png

Hope this helps!

Cheers,
Balmukund