DISTRIBUTED TRANSACTION: DTC in SQL server

There is two SQL servers and DTC is enabled both of them.

One SQL server is local and another one is a linked server named test.

Run a Distributed Transaction in SQL server for test purpose:

after running the T-SQL transaction you can check in the DTC report.

 

you can check the DTC connection and firewall settings:

DTC ping tool

In powershell:

If the remote server is another domain,  you will get an error:
New-CimSession : WinRM cannot process the request. The following error with errorcode 0x80090322 occurred while using Kerberos authentication: An unknown security error occurred.

In this case you can set: No Authentication Required.

 

DTC and Java

How to enable DTC in SQL server for Java:

– copy sqljdbc_xa.dll to sql server binn folder from the EXTRACTED (but not installed) jdbc driver
– enable xa transactions in component services > computerts > Distributed Transaction Coordinator > Local DTC (properties, security tab) Enable XA transactions
– restart sql server (all components to be sure)
– run script on master db. (xa_install.sql it is also in the jdbc driver, next to the .sql)
– the user that will perform distributed transactions must have the role “SqlJDBCXAUser” set on the MASTER db!

Windows Performance tools

  1. install WPT on the affected host. WPT is part of ADK. Or they can just download this archive – extract it on the server into C:\msdata folder. They should have at least 5Gb free space on that disk
  2. Run elevated CMD and execute:

#perf_counters

logman delete %computername%_IO

logman create counter %computername%_IO -c “\LogicalDisk(*)\*” “\Memory\*” “\Network Adapter(*)\*” “\Network Interface(*)\*” “\Paging File(*)\*” “\PhysicalDisk(*)\*” “\Process(*)\*” “\Processor Information(*)\*” -max 512 -f bincirc -si 00:00:01 -ow

logman start %computername%_IO

#etw_trace

C:\msdata\xperf -on PROC_THREAD+LOADER+PROFILE+INTERRUPT+DPC+FILENAME+FILE_IO+FILE_IO_INIT+FLT_IO_INIT+FLT_IO+FLT_FASTIO+FLT_IO_FAILURE+DISK_IO+DISK_IO_INIT -stackwalk Profile+FileCreate+FileCleanup+FileClose+FileRead+FileWrite+FileSetInformation+FileDelete+FileRename+FileDirEnum+FileFlush+FileQueryInformation+MiniFilterPreOpInit+MiniFilterPostOpInit+DiskReadInit+DiskWriteInit+DiskFlushInit -BufferSize 1024 -MinBuffers 256 -MaxBuffers 2048 -MaxFile 4096 -FileMode Circular

 

  1. In the folder C:\msdata create data_stop.cmd with following content:

logman stop %computername%_IO

C:\msdata\xperf -d C:\msdata\io.etl

  1. Then ask customer to find an event id 17883 in the application event log, do right click -> attach and “attach task to this event”, in action for the task point it to the script – C:\msdata\data_stop.cmd
  2. Also make sure following options set for the task:
    Run whehet user is logged on or not
    Runt with Hihgest privileges

 

Test it, write to the app event log:
Write-EventLog -LogName Application -EntryType Error -Source MSSQLSERVER -EventId 17883 -Message “TEST ERROR EVENT – PLEASE IGNORE IT.”

 

Test if they are running:

xperf -loggers “NT Kernel Logger”
or
logman query “NT Kernel Logger” -ets

 

If session exist – trace is running.

 

SQL server or agent or any other login can access a fileshare?

Yes, but you need to check:

 

 

LOGMAN for SQL Server

en example for

 

 

Increased the default XEvent trace: system_health size and retention policy are in SQL Server

If you want to investigate a case the default trace setting can be readable for few day and after that they are overwritten.

The default setting is 10 x 100 MB files.

You can check the oldest log:

Hey , it is only 3 days! you have to backup the files. A better solution to survive a long weekend to increase the retention, for example using 30 files:

 

 

Collect Index defragmentation

I do it for registered servers:

 

Install SSMS without Azure Data Studio

Starting with SSMS 18.7, SSMS installs a system version of Azure Data Studio by default. If an equal or greater system version of Azure Data Studio stable or insiders is already present on the workstation compared to the included version of Azure Data Studio, the installation of Azure Data Studio by SSMS is skipped. The Azure Data Studio version can be found in the release notes.

If you do not want to install ADS (Azure Data Studio) use the SSMS installer with the command line flag DoNotInstallAzureDataStudio=1.

 

 

 

 

SSISDB update failed during the SQL CU or SP udpate

Reason: the cu found a SSIDB and wanted to upgrade it.
It failed because SSIS component is not installed to the server.

It needs: Cannot bulk load. The file “C:\Program Files\Microsoft SQL Server\150\DTS\Binn\Microsoft.SqlServer.IntegrationServices.Server.dll” does not exist or you don’t have file access rights.
Yes it is missing , because SSIS component installed.

Without the ssisdb the sql server was not able to start.

It recommended to reinstall the master. Do NOT reinstall the master.

My solution was:

  1. Install (add ) the Integration Service component.
  2. Start the server with 902 flag (admin command prompt)

create a missing SQL login and connect to hte SSISD

 

Reason:

If you don’t create SSISDB locally (you attach by migration), the SQL login will missing.

 

Help:

After installing Integration service it gave enough hint:

2021-07-10 14:12:47.73 spid10s     Cannot find the login ‘##MS_SSISServerCleanupJobLogin##’, because it does not exist or you do not have permission.

2021-07-10 14:12:47.73 spid10s     Error: 912, Severity: 21, State: 2.

2021-07-10 14:12:47.73 spid10s     Script level upgrade for database ‘master’ failed because upgrade step ‘ISServer_upgrade.sql’ encountered error 15151, state 1, severity 16. This is a serious error condition which might interfere with regular operation and the database will be taken offline. If the error happened during upgrade of the ‘master’ database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion.

SUM: Please check if there is a SSIDB in the SQL server before install SP or CU.

Find and list read and writeable user databases which are only in local instance or in primary AG group

List database names, which are in AO AG:

Local databases , which are outside of AO AG:

Writeable databases : primary db or only in local instance