1

My idea is to trace a few days all statements (scripted the replay template) on a SQL Server 2008 r2 and replay those against a deployed version of the db on a newer version (SQL Server 2014).

Is a re-playable trace file suitable to figure out server version compatibility issues? Does this scenario make sense?

How can one realize problems? How are errors displayed when replaying queries that have issues?

Aaron Bertrand
  • 180,303
  • 28
  • 400
  • 614
Magier
  • 4,787
  • 8
  • 43
  • 87

1 Answers1

2

Before a replay, I would:

  1. Run the Upgrade Advisor and Best Practices Analyzer

  2. Run a trace looking for deprecation events

  3. Look for some of these issues; the above methods are unlikely to find all of them.

Note that none of the above, nor replaying the trace, are guaranteed to find all compatibility issues (consider the case where a stored procedure will only have a problem with very specific parameters are used, and those don't happen to be used during your trace).

And when you replay the trace, you'll have to parse the output file(s) or table(s) yourself, and perhaps even perform diffs to see any cases where there are errors on the new version that didn't happen on the old version. The replay doesn't produce a nice "here's what worked differently from the original activity" report. You can do this by simply performing a join against .

Here is a quick example I whipped up on my own system - you need to add the Error column to your trace, and note that I am absolutely not advocating Profiler for this, it was just the easiest way to demonstrate. First, on 2014, create a database using 100 compatibility level:

CREATE DATABASE Compat100;
GO
ALTER DATABASE Compat100 SET COMPATIBILITY_LEVEL = 100;
GO

Now, run these two batches:

USE Compat100;
GO
DECLARE @x TABLE(n DATETIME2, x AS CONVERT(CHAR(10), n)); -- not style 121
INSERT @x SELECT GETDATE();
-- error:
SELECT CONVERT(INT, LEFT(x,4)) FROM @x;
GO

USE tempdb;
GO
DECLARE @x TABLE(n DATETIME2, x AS CONVERT(CHAR(10), n)); -- style 121
INSERT @x SELECT GETDATE();
-- not an error:
SELECT CONVERT(INT, LEFT(x,4)) FROM @x;

A trace will yield these:

enter image description here

(Again, do not use Profiler for the actual work, this was just to quickly illustrate that a trace can capture error conditions, and that if you had these two batches run identically on two different servers, you should easily be able to join on TextData equality and Error inequality. And yes, I do realize that this example works the opposite way - the error happens on 2008 but works on 2014, but hopefully it still demonstrates the approach.)

Also see this tip.

Aaron Bertrand
  • 180,303
  • 28
  • 400
  • 614
  • TY, good tips. Question: "even perform diffs" - how? Besides duration there is no success/failure output available, is it? – Magier Aug 24 '15 at 16:35
  • Aaron, TY, you showed my how to trace an error using profiler (I have scripted trace configurations and do not use profiler to create trace files). But my scenario is a little different: I traced the actual working statements from a live db (2008 comp. 80!) and wanted to replay exactly this trace against another instance (2014) instead of trace it again, because on the new unused instance, there is no activity to trace. I already figured that when Re-Running, there are sometimes things shown in Profiler like "Replay Provider Error"... but this was just because of a Primary Key violation. – Magier Aug 24 '15 at 17:41
  • I just found that the Upgrade Advisor Tool does not support to check databases having compatibility 80. – Magier Aug 24 '15 at 17:45
  • Does the tracing of deprecated events consider the compatibility level setting of the traces database? – Magier Aug 24 '15 at 17:54
  • If you want to know if statements suddenly error on the newer version, you'll have to re-run your trace, sorry. You could assume all statements completed without error in the old server, but it could lead to red herrings. – Aaron Bertrand Aug 24 '15 at 18:00
  • Your 2008 R2 database was in 80 compat mode? Why? Why didn't you mention that in the question? You may be able to use the 2012 upgrade advisor, but I'm not sure. Also deprecated events should be picked up regardless of compat level, but honestly not something I've tested explicitly. – Aaron Bertrand Aug 24 '15 at 18:02
  • I can't tell why, I am only the heir who takes care. To be honest, I realized it after I asked the question. Meanwhile I managed to run the UA tool against a copy with compat 90 on SQL 2008. It tells me 0 unresolved issues found. But in the logfile I have hundreads of the following: "VERSION mismatch - Rule AUTOSTAT1 does not support scanning SQL Server instance with version 10.50.1600. SKU mismatch - Rule AUTOSTAT1 does not support scanning SQL Server instance with edition Enterprise Edition (64-bit)." So I still don't know if there is something wrong. – Magier Aug 25 '15 at 11:36
  • The REPLAY of an about 400 MB trace file against a copy on SQL2014. Now I am looking at a huge trace list that was re-executed and another list that protocols this. It has 3.5 Milion entries, I have no clue how to identify any compatibility issues right now? – Magier Aug 25 '15 at 11:36