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

server closed the connection unexpectedly #362

Open
CR0NYM3X opened this issue Jul 19, 2024 · 2 comments
Open

server closed the connection unexpectedly #362

CR0NYM3X opened this issue Jul 19, 2024 · 2 comments

Comments

@CR0NYM3X
Copy link

Issue report

The following information is very important in order to help us to help you. Omission of the following details cause delays or could receive no attention at all.

Operating system

On recent GNU/Linux distributions, you can provide the content of the file /etc/os-release

NAME="Red Hat Enterprise Linux"
VERSION="8.10 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.10"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.10 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8::baseos"
HOME_URL="https://www.redhat.com/"
DOCUMENTATION_URL="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.10
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.10"

Version of tds_fdw

From a psql session, paste the outputs of running \dx

If you built the package from Git sources, also paste the output of running git log --source -n 1 on your git clone from a console

postgres@postgres# \dx tds_fdw
                                           List of installed extensions
+---------+---------+--------+-----------------------------------------------------------------------------------+
|  Name   | Version | Schema |                                    Description                                    |
+---------+---------+--------+-----------------------------------------------------------------------------------+
| tds_fdw | 2.0.3   | public | Foreign data wrapper for querying a TDS database (Sybase or Microsoft SQL Server) |
+---------+---------+--------+-----------------------------------------------------------------------------------+
(1 row)

Version of PostgreSQL

From a psql session, paste the output of running SELECT version();

postgres@postgres# SELECT version();
+---------------------------------------------------------------------------------------------------------+
|                                                 version                                                 |
+---------------------------------------------------------------------------------------------------------+
| PostgreSQL 16.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22), 64-bit |
+---------------------------------------------------------------------------------------------------------+
(1 row)

Version of FreeTDS

How to get it will depend on your Operating System and how you installes FreeTDS

From a console:

  • On RPM based systems: rpm -qa|grep freetds
  • On Deb based systems: dpkg -l|grep freetds
  • If you built your own binaries from source code, then go to the sources, and run: grep 'AC_INIT' configure.ac
$ rpm -qa|grep freetds
freetds-1.4.16-1.el8.x86_64
freetds-libs-1.4.16-1.el8.x86_64

Logs

Please capture the logs when the error you are reporting is happening, as well as commands with their outputs if you are reporting a problem build or installing

For problems using tds_fdw on PostgreSQL how to do it will depend on your system, but if your PostgreSQL is installed on GNU/Linux, you will want to use tail -f with the log of the PostgreSQL cluster

For MSSQL you will need to use the SQL Server Audit Log

Replace this with the commands and outputs

Sentences, data structures, data

This will depend on the exact problem you are having and data privacy restrictions

However the more data you provide, the more likely we will be able to help

As a bare minimum, you should provide

  • The SQL sentence that is failing
  • The data structure on the PostgreSQL side and on the MSSQL side

  CREATE SERVER mssql_master FOREIGN DATA WRAPPER tds_fdw OPTIONS (servername '192.168.5.100', port '1422', database 'master'); 
  CREATE USER MAPPING FOR postgres  SERVER mssql_master OPTIONS (username 'systest', password '123123123');



CREATE FOREIGN TABLE  "new_schema_test".propiedades_instancia (
 computername text  )
 
    SERVER mssql_master
   OPTIONS ( row_estimate_method 'showplan_all'    ,   query 'select SERVERPROPERTY("MachineName") AS computername'    );


postgres@postgres#  select *from propiedades_instancia  ;

         server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
The connection to the server was lost. Attempting reset: Failed.
Time: 1222.050 ms (00:01.222)
@>?
@>?




[NOTE] -> USER systest is sysadmin , try different versions of sql and same problem on same server

 select @@version
 Microsoft SQL Server 2022 (RTM-CU13-GDR) (KB5040939) - 16.0.4131.2 (X64)   Jun 21 2024 21:57:17   Copyright (C) 2022 Microsoft Corporation  Standard Edition (64-bit) on Windows Server 2022 Standard 10.0 <X64> (Build 20348: ) (Hypervisor) 

Microsoft SQL Server 2017 (RTM-CU31-GDR) (KB5040940) - 14.0.3471.2 (X64)   Jun 20 2024 09:33:43   Copyright (C) 2017 Microsoft Corporation  Standard Edition (64-bit) on Windows Server 2022 Standard 10.0 <X64> (Build 20348: ) (Hypervisor) 


@CR0NYM3X
Copy link
Author

I can make other queries but that one won't let me
"select SERVERPROPERTY("MachineName") AS computername"

@CR0NYM3X
Copy link
Author

I found the solution :)
you need to put a data type that will return

select cast(SERVERPROPERTY('MachineName') as varchar(255) ) AS computername

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

No branches or pull requests

1 participant