VS Shell installation has failed with exit code 1638

-> SQL Server 2016 installation failed with below error,

TITLE: Microsoft SQL Server 2016 Setup
——————————
The following error has occurred:
VS Shell installation has failed with exit code 1638.

For help, click: http://go.microsoft.com/fwlink?LinkID=20476&ProdName=Microsoft%20SQL%20Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=13.0.5026.0&EvtType=0x5B39C8B9%25401434%25403
——————————
BUTTONS:
OK
——————————

-> In my case, all components completed fine except Integration Services. Below was the error found during setup for Integration services,

Action required:
Use the following information to resolve the error, and then try the setup process again.
Feature failure reason:
An error occurred for a dependency of the feature causing the setup process for the feature to fail.
Error details:
§ Error installing Microsoft Visual C++ 2015 Redistributable
VS Shell installation has failed with exit code 1638.
Error code: 1638
Log file: C:\Program Files\Microsoft SQL Server\130\Setup Bootstrap\Log\20191119_153017\VCRuntime140_x64_Cpu64_1.log
Visit http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=13.0.5026.0&EvtType=VCRuntime140_x64%40Install%400×1638 to get help on troubleshooting.
Product Update:
Product Update has successfully applied KB 4052908 <http://support.microsoft.com/?id=4052908&gt;. These updates have set the patch level of the Setup operation to 13.2.5026.0.

-> Above error is pretty clear that it is not able to install Microsoft Visual C++ 2015 Redistributable.

-> Details.txt contained below message/error,

(04) 2019-11-19 15:42:11 Slp: The directory monitor thread is interrupted due to the following exception while monitoring the notifications for directory ‘C:\Program Files\Microsoft SQL Server\’
(04) 2019-11-19 15:42:11 Slp: The following is an exception stack listing the exceptions in outermost to innermost order
(04) 2019-11-19 15:42:11 Slp: Inner exceptions are being indented
(04) 2019-11-19 15:42:11 Slp:
(04) 2019-11-19 15:42:11 Slp: Exception type: Microsoft.SqlServer.Configuration.Sco.MonitorThreadInterruptedException
(04) 2019-11-19 15:42:11 Slp: Message:
(04) 2019-11-19 15:42:11 Slp: The directory monitor thread is interrupted. Message: ‘The directory monitor thread is interrupted due to a StopMonitor call.’
(04) 2019-11-19 15:42:11 Slp: HResult : 0x86a40016
(04) 2019-11-19 15:42:11 Slp: FacilityCode : 1700 (6a4)
(04) 2019-11-19 15:42:11 Slp: ErrorCode : 22 (0016)
(04) 2019-11-19 15:42:11 Slp: Data:
(04) 2019-11-19 15:42:11 Slp: ErrorMessage = The directory monitor thread is interrupted due to a StopMonitor call.
(04) 2019-11-19 15:42:11 Slp: WatsonData = Microsoft.SqlServer.Configuration.Sco.MonitorThreadInterruptedException@22
(04) 2019-11-19 15:42:11 Slp: Stack:
(04) 2019-11-19 15:42:11 Slp: at Microsoft.SqlServer.Configuration.Sco.DirectoryMonitor.Monitor()

-> Tried this article. But Integration Services installation failed again with same error.

-> Checked Add/Remove programs for list of “Microsoft Visual C++ ….” installation and I could see Visual C++ 2013, 2015, 2017 Redistributable  installed.

-> I was installing SQL Server 2016 on a new server with no other SQL Server instances. So i thought of uninstalling Microsoft Visual C++ 2015, 2017 Redistributable both X64, X86 and start the install again. But, I couldn’t uninstall from Add/Remove programs.

-> When I click on Microsoft Visual C++ 2015, 2017 Redistributable and clicked on Modify or Uninstall, nothing happened. Couldn’t see any uninstall/Modify dialog box coming up. I even tried that after restarting the server, but no luck.

-> Executed below from administrative command prompt.


"C:\ProgramData\Package Cache\{80586c77-db42-44bb-bfc8-7aebbb220c00}\VC_redist.x64.exe" /uninstall

"C:\ProgramData\Package Cache\{3ee5e5bb-b7cc-4556-8861-a00a82977d6c}\VC_redist.x64.exe" /uninstall

"C:\ProgramData\Package Cache\{206898cc-4b41-4d98-ac28-9f9ae57f91fe}\VC_redist.x86.exe" /uninstall

"C:\ProgramData\Package Cache\{6c6356fe-cbfa-4944-9bed-a9e99f45cb7a}\VC_redist.x64.exe" /uninstall

-> Please note that, I performed above action as this was a new database server and had no worries of any existing SQL Server instances.

-> Rebooted the server and performed the SQL Server Integration Services install again and this time it installed just fine.

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.

Error 1311.Source file not found: C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Update Cache\KB4018073\ServicePack\redist\VisualStudioShell\VC10SP1\vc_red.msi. Verify that the file exists and that you can access it.

-> I was applying SQL Server 2012 Service Pack 4 on a database server. It failed with below error,

Instance MSSQLSERVER overall summary:
Final result: The patch installer has failed to update the shared features. To determine the reason for failure, review the log files.
Exit code (Decimal): -2068709375
Exit facility code: 1202
Exit error code: 1
Exit message: The required MSI package ‘C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Update Cache\KB4018073\ServicePack\redist\VisualStudioShell\VC10SP1\vc_red.msi’ doesn’t exist.
Start time: 2018-02-20 09:54:47
End time: 2018-02-20 09:57:19
Requested action: Patch
Exception help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.7001.0&amp;
EvtType=0xB34122F7%400xF762992B%401202%401&EvtType=0xB34122F7%400xF762992B%401202%401
Feature: Database Engine Services
Status: Failed: see logs for details
Reason for failure: An error occurred for a dependency of the feature causing the setup process for the feature to fail.
Next Step: Use the following information to resolve the error, and then try the setup process again.
Component name: Microsoft Visual Studio 2010 Redistributables
Component error code: 1311
Component log file: C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\20180220_103719\MSSQLSERVER\VC10Redist_Cpu64_1.log
Error description: Error 1311.Source file not found: C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Update Cache\KB4018073\ServicePack\redist\VisualStudioShell\VC10SP1\vc_red.msi. Verify that the file exists and that you can access it.
Error help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.7001.0&amp;
EvtType=vc_red.msi%40InstallFiles%401311

-> There were no missing MSI/MSP file. I extracted SQL Server 2014 Service Pack 4 KB4018073 to C:\temp\SP4 and searched for vc_red.msi file.

-> I placed the files vc_red.msi and vc_red.cab from C:\temp\SP4\redist\visualstudioshell\vc10sp1\x64 to C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Update Cache\KB4018073\ServicePack\redist\VisualStudioShell\VC10SP1\.

-> Started the patch and it failed with below error,

Feature: Database Engine Services
Status: Failed: see logs for details
Reason for failure: An error occurred for a dependency of the feature causing the setup process for the feature to fail.
Next Step: Use the following information to resolve the error, and then try the setup process again.
Component name: Microsoft Visual Studio 2010 Redistributables
Component error code: 1642
Component log file: C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\20180220_104714\MSSQLSERVER\VC10Redist_Cpu32_1.log
Error help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&amp;
ProdVer=11.0.7001.0&EvtType=vc_red.msi%400x162A16FE%400×1642

-> Replaced the files vc_red.msi and vc_red.cab from C:\temp\SP4\redist\visualstudioshell\vc10sp1\x86 to C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Update Cache\KB4018073\ServicePack\redist\VisualStudioShell\VC10SP1\.

-> Started the patching again and it completed fine without any issues.

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.

SQL services fails after applying service pack

-> I applied service pack on one of the SQL instance in a 2 node cluster. After applying the service pack, SQL services failed to come online.

-> I applied service pack on passive node first and then on the active node. The install went fine without any issues. But after the service pack upgrade SQL server did not start.

-> Checked the SQL server error log and found that the SQL server fails during script upgrade mode with below error.

2016-12-08 23:57:25.43 spid8s      DBCC execution completed. If DBCC printed error messages, contact your system administrator.
2016-12-08 23:57:25.43 spid8s      Error: 537, Severity: 16, State: 3.
2016-12-08 23:57:25.43 spid8s      Invalid length parameter passed to the LEFT or SUBSTRING function.
2016-12-08 23:57:25.43 spid8s      Error: 912, Severity: 21, State: 2.
2016-12-08 23:57:25.43 spid8s      Script level upgrade for database ‘master’ failed because upgrade step ‘sqlagent100_msdb_upgrade.sql’encountered error 537, state 3, 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.
2016-12-08 23:57:25.43 spid8s      Error: 3417, Severity: 21, State: 3.
2016-12-08 23:57:25.43 spid8s      Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. For more information about how to rebuild the master database, see SQL Server Books Online.
2016-12-08 23:57:25.43 spid8s      SQL Trace was stopped due to server shutdown. Trace ID = ‘1’. This is an informational message only; no user action is required.
2016-12-08 23:57:25.46 Logon       Error: 18401, Severity: 14, State: 1.
2016-12-08 23:57:25.46 Logon       Login failed for user ‘iuser_SitefinityFrontier’. Reason: Server is in script upgrade mode. Only administrator can connect at this time. [CLIENT: 66.133.172.174]

-> Added -T902 to stop script upgrade mode. Started the SQL services, it started without issues. Checked the owner for MSDB and Master. Both were having SA as owner.

902 Bypasses execution of database upgrade script when installing a Cumulative Update or Service Pack.

-> Searched for sqlagent100_msdb_upgrade.sql file and opened it.

-> The script upgrade mode was failing on below set of statement in file sqlagent100_msdb_upgrade.sql,

SELECT @device_directory = SUBSTRING(filename, 1, CHARINDEX(N’master.mdf’, LOWER(filename)) – 1)  FROM master.dbo.sysaltfiles
WHERE (name = N’master’)

-> The SQL server instance did have more than one database with logical name “master”.

-> Query “”SELECT db_name(dbid) FROM master.dbo.sysaltfiles WHERE (name = N’master’)”” returned 3 databases including master database in my SQL server instance.

-> Variable @device_directory can contain only one value. But in our case 3 values were returned and thats the reason we got this error.

-> I detached the 2 databases.

-> Ran Query “”SELECT db_name(dbid) FROM master.dbo.sysaltfiles WHERE (name = N’master’)”” and it returned just master database.

-> Removed the startup parameter -T902 and started the SQL service from cluadmin.msc.

-> SQL server started this time without issues. Script upgrade mode completed fine without any issues and the version changed to appropriate value.

-> Failed over the SQL instance to other node and it came online without issues.

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.