During implementation of our new PS finance environment I was given the task to explore the use of SQL 2008’s Resource Governor capabilities. We wanted, if possible, to categorize such transactions as; batch, psquery, administrative, and other. This was to ensure someone running a psquery, batch, or administrative transaction couldn’t take over the whole server.
Well I’m new to Peoplesoft and thought I’d give it a go. So first thing I had to do was understand how PS logs into SQL Server. That wasn’t so hard. In short, PS uses connection pooling and comes in as a user with access to it’s database. This user has dbo rights. They’re are a finite amount of connections (worker processes) made at startup for normal processing. Then depending on how the PS Admins set things up, a connection can be made on the fly or it can grab an existing connection. From here the first thing it does is query some PS tables to see if the PS login has rights to what it needs. But again, it does all of this with just a single sql login account. What it does do, is update the context_info field that resides in sys.dm_exec_requests. This field can be helpful when things are bogged down and the dba wants to know who is executing what within sql. The DBA could run something like:
select session_id, cast(context_info as varchar(max)) OPRID, qt.text, DB_NAME(database_id) as dbname ,wait_type,wait_time,wait_resource, blocking_session_id from sys.dm_exec_requests cross apply sys.dm_exec_sql_text(sql_handle) qt ; GO
It shows some info specific to the to the PS user running the query and then the actual query it’s running.
That’s good to know, but resource governor doesn’t work that way. It doesn’t look at the context of a running transaction. It looks at things at the time the connection is made. I wasn’t going to give up quite yet though. I knew it would be easy to classify most batch processing as that would come from the PS Process Scheduling server. Not the application server that does the normal day-to-day processing. The tough one becomes ps query. This as far as I understand it… at startup on the application server a configured amount of processes start for handling psquery. You can see the process(es) under task manager. And even in the startup logs. So my thought was, if I could somehow get the pid of the psquery process. I’d know at connection by using the hostprocess column in sys.sysprocesses if it were requested from psquery or not. Currently the only method I can think of doing this, and it wouldn’t be fun… is to somehow get the pid from the logs at startup and update a table somewhere on the sql instance. Then in my classifier function I could query that table to see if the pid matches hostprocess. That just sounded like too many loops and too much work to get ps queries into a designated bucket. So for now I scrapped it. Lastly, all administrative tasks that are scheduled will run a specific user. So in our case you can just classify on that user. There are many ways you can go for that one though, all of which have discussed at nausium.
The one that got away was the psquery stuff… so if anybody has an idea. I’m open to suggestions.
VN:F [1.7.5_995]
Rating: 8.0/10 (1 vote cast)
VN:F [1.7.5_995]
UPDATE: Bad File
In regards to my previous post about an erroneous log file entry: http://mattabase.com/archives/295
As I thought I couldn’t get Microsoft to sign-off on altering the system tables. So I created another workaround that gets rid of the file. It involves there own procedures of detach, attach, create file, and remove file… so it had to be supported. I ran it by them anyway just to make sure and they gave me the green light. So I did it and it was successful. Here are the steps:
1. Make sure to attempt to delete bad log file and get error message about not being initialized (does part of cleanup). ie:
ALTER DATABASE [testy] REMOVE FILE [testy_log2]
GO
2. Check with dbcc loginfo whether or not the bad log file is in use
a. If it is then your going to have to switch the database into simple recovery for a second…
b. If the log is not in use then continue…
3. Detach database
4. Reattach and make sure there are only 2 log file entries in sys.sysaltfiles now
5. Create temp datafile with…
ALTER DATABASE [testy] ADD FILE ( NAME = N’testy_temp’, FILENAME = N’C:\testy_temp2.ndf’ , SIZE = 2048KB , FILEGROWTH = 1024KB ) TO FILEGROUP [PRIMARY]
GO
6. Delete both files in like so (in the same order)
ALTER DATABASE [testy] REMOVE FILE [testy_log2]
GO
ALTER DATABASE [testy] REMOVE FILE [testy_temp]
GO
7. Detach database
8. Attach database
9. Check sysaltfiles (should be gone)
If you were unlucky enough to have the bad log file in use then don’t forget to flip it back to full recovery and take a full backup to start a new log chain.