Open cloudshiftchris opened 1 year ago
Originally the query had a ROW_NUMBER construct that also appeared to cause (at least, in part) the hanging.
Possibly related. Driver hangs even when not expecting a result set.
For example, a simple call to sp_addarticle hangs indefinitely when using the Exec method, which doesn't expect results.
E.g...
qry = "exec sp_addarticle @force_invalidate_snapshot = 1, @publication = N'EXMPL', @article = N'" + filter.Table + "', @source_owner = N'dbo', @source_object = N'" + filter.Table + "', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509F, @identityrangemanagementoption = N'manual', @destination_table = N'" + filter.Table + "', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'CALL [sp_MSins_dbo" + filter.Table + "]', @del_cmd = N'CALL [sp_MSdel_dbo" + filter.Table + "]', @upd_cmd = N'SCALL [sp_MSupd_dbo" + filter.Table + "]'"
fmt.Println("Adding to replication:\n", qry)
_, err = sqlserv.Exec(qry)
if err != nil {
log.Println(err)
break
}
Reproducer available. Execute via
./go-mssql-repro-1 --hostname <ip> --username <username> --password <password>
When executing queries (with certain attributes, detailed below) that do not return a result set the driver hangs, expecting to read data that isn't ever coming.
Using this based-on-real-world-issue query as an exemplar:
As written the driver hangs executing that query, never to return. Removing the ORDER BY or TOP clause prevents hanging. Other nearly identical queries (with WHERE clauses that match results) do not hang.
To Reproduce Reproducer available. Execute via
./go-mssql-repro-1 --hostname <ip> --username <username> --password <password>
Expected behavior
Expecting that empty result sets are returned successfully, with rows.Next() returning false on first call.
Further technical details
SQL Server version: SQL Server 2019 Operating system: MacOS 13.1 M1 Pro