spaghettidba / WorkloadTools

A collection of tools to collect, analyze and replay SQL Server workloads, on premises and in the cloud
MIT License
232 stars 52 forks source link

Replay to database with another name #80

Closed fvanderhaegen closed 4 years ago

fvanderhaegen commented 4 years ago

I'm trying to replay a workload to a database with name that is different from the source database. The workload has been captured in a sqllite file.

When I check the source code of the ReplayWorker I found following code snippet: if (conn.Database != command.Database) { logger.Trace($"Worker [{Name}] - Changing database to {command.Database} "); conn.ChangeDatabase(command.Database); }

When the databasename of the connection doesn't match the name of the database in the sqllite file it is changed.

Is there a reason why a workload can't be replayed on a database with a different name?

spaghettidba commented 4 years ago

Hi, the reason is because the source workload could be coming from multiple databases. If you capture a workload on database A and database B, when you replay it what you want is each command replayed against its respective database. Ostress solved this issue using a map of database id/database name. I could probably do something similar here, like having a map of databases and the desired target database during the replay. Something like this:

Would that work for you? In case I'll be glad to code a solution for you.

fvanderhaegen commented 4 years ago

Oh, now I understand this better. I'll also first explain what I try to do.

I've a database on a AG and I'll want to test some changes before I'll put them in production. So I restored the database on the secondary/passive replica as another database. Now I want to replay the workload and analyze the performance but the queries are al pointed to the non-readable database. It is the intention to do a realtime replay but for now I'm using a sqllite file.

The solution you propose would solve the issue for me.

Thanks

spaghettidba commented 4 years ago

OK, I'll try to implement it ASAP