sql-server add tag
John K N
I recently had a database that was in the `Recovering...` state after the Windows Server on which the SQL Server instance resides had been rebooted. The database that was in the `Recovering...` state is a database that uses the instances Filestream feature.

Following are excerpts from the SQL Server ERRORLOG  file.

## Reboot of Windows Server 

    2020-08-30 20:25:42.20 Server      SQL Server is terminating because of a 
                                       system shutdown. This is an informational 
                                       message only. No user action is required.
                                       
## Restart of SQL Server instance

    2020-08-30 20:26:32.21 Server      Microsoft SQL Server 2017 (RTM-GDR) 
    								   (KB4505224) - 14.0.2027.2 (X64) 
	                                   Jun 15 2019 00:26:19 
	                                   Copyright (C) 2017 Microsoft Corporation
                                       Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 
                                       <X64> (Build 14393: ) (Hypervisor)
    2020-08-30 20:26:32.22 Server      UTC adjustment: 2:00
    2020-08-30 20:26:32.22 Server      (c) Microsoft Corporation.
    2020-08-30 20:26:32.22 Server      All rights reserved.
    2020-08-30 20:26:32.22 Server      Server process ID is 3752.
    2020-08-30 20:26:32.22 Server      System Manufacturer: 'VMware, Inc.',     
                                       System Model: 'VMware Virtual Platform'.
    2020-08-30 20:26:32.22 Server      Authentication mode is MIXED.
    2020-08-30 20:26:32.22 Server      Logging SQL Server messages in file                             
                                       'E:\MSSQL14.INSTANCE\MSSQL\Log\ERRORLOG'.
    2020-08-30 20:26:32.22 Server      The service account is 'DMN\saServicesAccount'. This is an 
                                       informational message; no user action is required.
    2020-08-30 20:26:32.22 Server      Registry startup parameters:
                                       -d E:\MSSQL14.INSTANCE\MSSQL\DATA\master.mdf
                                       -e E:\MSSQL14.INSTANCE\MSSQL\Log\ERRORLOG
                                       -l E:\MSSQL14.INSTANCE\MSSQL\DATA\mastlog.ldf
    2020-08-30 20:26:32.22 Server      Command Line Startup Parameters:
                                       -s "INSTANCE"
    2020-08-30 20:26:33.43 Server      SQL Server detected 4 sockets with 2 
                                       cores per socket and 2 logical 
                                       processors per socket, 8 total logical 
                                       processors; using 8 logical processors 
                                       based on SQL Server licensing. This is 
                                       an informational message; no user action 
                                       is required.
    2020-08-30 20:26:33.43 Server      SQL Server is starting at normal 
                                       priority base (=7). This is an 
                                       informational message only. No user 
                                       action is required.
    ....
    2020-08-30 20:26:41.14 spid27s     Starting up database 'Document'.

## Filestream Error

Shortly after the instance is up and running, the SQL Server instance tries to initialise the Filestream "devices".

    2020-08-30 20:26:38.51 spid5s      CHECKDB for database 'master' finished without errors on 2020-08-30 02:00:01.157 (local time). This is an informational message only; no user action is required.
    2020-08-30 20:26:38.52 spid5s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
    2020-08-30 20:26:38.53 spid5s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
    <{942949C8-7DFD-45B9-BA7B-AC5B0D5D4FB2}>RsFxMgmtInitialize failed (the RsFx device is not ready.): Error 0x80070015 (-2147024875)
    2020-08-30 20:26:38.65 spid5s      FILESTREAM: failed to connect to kernel driver RsFx0501.
    <{1038F43D-3391-45F7-B1B3-BADF26459429}>Failed to initialize CFsaShareFilter: Error 0x80070015 (-2147024875)
    2020-08-30 20:26:38.65 spid5s      FILESTREAM: effective level = 0, configured level = 2.
    2020-08-30 20:26:38.65 spid5s      A failure occurred while FILESTREAM configuration was being 
                                       changed or applied. For more information, see the SQL Server 
                                       error log.

This fails with the above errors.

## Filestream Error (Resumed)

As a consequence the Filestream feature is not activated for the instance.


    2020-08-30 20:26:42.31 spid27s     Error: 5591, Severity: 16, State: 5.
    2020-08-30 20:26:42.31 spid27s     FILESTREAM feature is disabled.
    2020-08-30 20:26:42.31 spid27s     Error: 5105, Severity: 16, State: 14.
    2020-08-30 20:26:42.31 spid27s     A file activation error occurred. The physical file name 
                                       'I:\INSTANCE\DMS_FS1' may be incorrect. Diagnose and correct 
                                       additional errors, and retry the operation.
    2020-08-30 20:26:42.32 spid27s     Error: 5591, Severity: 16, State: 5.
    2020-08-30 20:26:42.32 spid27s     FILESTREAM feature is disabled.
    2020-08-30 20:26:42.32 spid27s     Error: 5105, Severity: 16, State: 14.
    2020-08-30 20:26:42.32 spid27s     A file activation error occurred. The physical file name 
                                       'I:\INSTANCE\DMS_FS2' may be incorrect. Diagnose and correct 
                                       additional errors, and retry the operation.



## Resulting Issues

Because the database `DOCUMENT` relies on the Filestream feature, it is unable to come online and is listed as `(Recovering...)` in the database tree of SSMS. There are no additional entries in the ERRORLOG files for the `DOCUMENT` database.

----

## Tried and Failed

I tried the following commands to bring the database `DOCUMENT` back online.

    RESTORE DATABASE [DOCUMENT] WITH RECOVERY
    GO
    
This didn't work.

    ALTER DATABASE [DOCUMENT] SET OFFLINE WITH ROLLBACK IMMEDIATE
    GO
    ALTER DATABASE [DOCUMENT] SET ONLINE
    GO
    
This failed too.

    EXEC sp_configure 'show advanced options'
    GO
    EXEC sp_configure filestream_access_level, 2
    GO
    RECONFIGURE WITH OVERRIDE
    GO

And no luck with the above instance configuration.



## Solution

The simple solution was to restart the SQL Server instance.  

----

# Question

Because my instance is hosting multiple databases I was wondering if there is an alternate solution to bring the ailing `DOCUMENT` database back online without restarting the whole SQL Server instance?

Top Answer
i-one
It looks that FILESTREAM initialization happens when RsFx driver is not well initialized yet. The RsFx is file system minifilter driver, it is used by the SQL Server to expose FILESTREAM content via UNC-share.

As per the log, the first portion of filestream errors is instance-wide FILESTREAM initialization (`CFsaShareFilter` is internal component of the SQL Server that interacts with RsFx driver). The second portion of filestream errors is per database initialization.

Apparently per database FILESTREAM initialization cannot succeed if instance-wide one did not. So, nothing but the instance restart remains, I'm afraid. Attempts to bring database online could succeed probably, if there was a retry of instance-wide FILESTREAM initialization on error. May be it exists though, but did not happened due to a good reason, I don't know. Retrying when OS reports that driver signature cannot be verified is pointless, for example.

I noticed that SQL Server instance build reported in the ERRORLOG is

```none
Microsoft SQL Server 2017 (RTM-GDR) (KB4505224) - 14.0.2027.2
```

whereas the [latest](https://support.microsoft.com/en-us/help/4047329) build (as of the day of writing this answer) is

```none
Microsoft SQL Server 2017 (RTM-CU21) (KB4557397) - 14.0.3335.7
```

That RTM-CU21 [build](https://support.microsoft.com/en-us/help/4557397) has special notice regarding FILESTREAM feature, which mentions `CFsaShareFilter` initialization error (with different error code though). There is a chance that something was done around the problem. Applying latest OS updates is probably worth to try too.

Alternatively, workaround with delayed instance start (via Task Scheduler) is reported [here](https://social.msdn.microsoft.com/Forums/en-US/5194f29e-2d54-49dd-bb9a-cea0b2248c2e/filestream-failed-to-connect-to-kernel-driver-rsfx0502?forum=sqldatabaseengine) as successful.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.