IN SQL Server 2012 Enterprise edition, you can use AlwaysON Availability groups to achieve what you want.
If you have 2 servers set up, then you can configure AlwaysON.
Primary server will be your main and secondary (Replica) - when configured as "Readable" will allow you to redirect all "Read Intent" requests to secondary replica as well as the secondary replica is a read-only replica.
Note that, your clients are connected to the Availability Group using Listener, which allows seamless failover for your application.
In case of disaster you have all your concerns covered
A. Not have boxes sitting around doing nothing waiting for a failure.
The secondary will be used for read intent requests and will server as a standby server in case the primary fails.
B. Automatic fail over. We don't want to be running like headless chickens flipping switches and configuration settings when a database / box fails
When you use synchronous mode, it will allow you for automatic failover. In my testing, asynchronous mode (without automatic failover - manual failover) has proven more benefits in terms of performance. SO depending on the data loss allowed by your company and the downtime, you can choose between them.
AlwaysON allows you to Configure Flexible Failover Policy to Control Conditions for Automatic Failover
C. Sensible fail-over times (e.g. a five minute fail over is not sustainable)
AlwaysON will provide failover in terms of seconds, but it depends on your n/w.
EDIT :
If you implement AlwaysON (which fits in your situation), below is my recommendation:
Assuming (from your post) DB1 is the main database and DB2 is for reporting.
Configure DB1 as primary in AlwaysON. You get a warm standby database on the secondary server (say DB1_Replica).
Configure DB1_Replica as readable and have asynchronous-Commit mode configured.
Under asynchronous-commit mode, the secondary replica never becomes synchronized with the primary replica. Though a given secondary database might catch up to the corresponding primary database, any secondary database could lag behind at any point. Asynchronous-commit mode can be useful in a disaster-recovery scenario in which the primary replica and the secondary replica are separated by a significant distance and where you do not want small errors to impact the primary replica or in or situations where performance is more important than synchronized data protection. Furthermore, since the primary replica does not wait for acknowledgements from the secondary replica, problems on the secondary replica never impact the primary replica.
The listener is going to help you with seamless failover.
Refer to below links to get you started :
A request that is being blocked does no work. Here's an example:
Create a blocking query
use AdventureWorks2012;
go
begin tran;
update HumanResources.Department
set Name = 'testing 1 2 3'
where DepartmentID = 7;
--rollback tran;
Run a query that will be blocked by the above session
use AdventureWorks2012;
go
select *
from HumanResources.Department;
Now look at any "work" this blocked request could be doing (query sys.dm_exec_requests
for this blocked session, and then wait some time and query again to compare/contrast):
select
start_time,
status,
total_elapsed_time_sec =
total_elapsed_time / 1000,
cpu_time,
reads,
logical_reads,
writes
from sys.dm_exec_requests
where session_id = 52; -- my blocked session's spid
waitfor delay '00:00:10';
select
start_time,
status,
total_elapsed_time_sec =
total_elapsed_time / 1000,
cpu_time,
reads,
logical_reads,
writes
from sys.dm_exec_requests
where session_id = 52; -- my blocked session's spid
What you see here is a request that is doing no work, as it is not in the running
state. When it is suspended
then it is not on a processor doing any work.
Best Answer
No, dropping a synonym requires a Sch-M lock, and also IX locks on
sysschobjs
/sysobjvalues
, at least if it is on the same server (I haven't tested what happens when the synonym uses a 4-part name).What exactly would it mean if you could change a synonym in the middle of a query or transaction? If you have a query plan operator or a cursor which needs to go back to the table, or you have multiple steps in a transaction that reference the table, it would violate all kinds of principles if the referenced table were different. I think it is much better that you can't change it until a point where nobody is referencing it.