Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commands around Suspect pages in a database #2191

Open
wsmelton opened this issue Sep 3, 2017 · 7 comments
Open

Commands around Suspect pages in a database #2191

wsmelton opened this issue Sep 3, 2017 · 7 comments

Comments

@wsmelton
Copy link
Member

@wsmelton wsmelton commented Sep 3, 2017

Feature Request

A simple command that just pulls readable information from msdb..suspect_pages.

Problem to solve

At times you need to monitor the suspect pages a server may have or verify after you get logical errors returned from DBCC results, or even finding the dreaded 823/824 errors in the error log.

You can run SELECT * FROM msdb..suspect_pages but that gives you a bunch of values that are all int and bigint, and one datetime value. So purpose would be to make it readable and provide full descriptive value for each ID.

Other noteworthy things to mention that could lead to commands:

  • The table has a limit of 1k rows
  • The table, being that it has a limit, is most commonly cleared after the pages previously recorded as a suspect page have been fixed. (e.g. Clear-DbaSuspectpages)

Each command below should allow multiple server and database names to be passed in.

Get-DbaSuspectPages

It does not require reference to Db or Database in the command since I believe the table sits in msdb so it is a server-level "object" technically. We could have a -Database filter on it if desired.

I would also have to believe the name of the command is kept as plural because the object it is reading is called "pages" and not "page"...but I'll defer to the boss on that decision.

The information returned from the table itself should be translated into readable information. There should be commands already in the module that can translate these IDs, with the exception of the page ID value.

Column name Data type Description
database_id int ID of the database to which this page applies.
file_id int ID of the file in the database.
page_id bigint ID of the suspect page. Every page has a page ID that is a 32-bit value identifying the location of the page in the database. The page_id is the offset into the data file of the 8 KB page. Each page ID is unique in a file.
event_type int The type of error; one of: 1 = An 823 error that causes a suspect page (such as a disk error) or an 824 error other than a bad checksum or a torn page (such as a bad page ID). 2 = Bad checksum. 3 = Torn page. 4 = Restored (page was restored after it was marked bad). 5 = Repaired (DBCC repaired the page). 7 = Deallocated by DBCC.
error_count int Number of times the error has occurred.
last_update_date datetime Date-and-time stamp of the last update.

Clear-DbaSuspectPages

Offer the ability to clear only those pertaining to a certain ID values, or the whole table.

Test-DbaSuspectPages

Basic command that just groups the data found in the table by each database and event type then returns the count of each.

@gbargsley
Copy link
Contributor

@gbargsley gbargsley commented Sep 20, 2017

I have the function working in test. Question on your notes.

Should we make a Clear function? The wording on MSDN says that as the suspect pages are fixed the table is updated. Could it cause issues removing records?

I will see if I can get the logic worked out for the grouping for Test function.

@potatoqualitee
Copy link
Member

@potatoqualitee potatoqualitee commented Sep 20, 2017

(btw @ConstantineK is almost done with his database breaker)

@wsmelton
Copy link
Member Author

@wsmelton wsmelton commented Sep 24, 2017

@gbargsley yes you do need to clear that table. The record in the table is updated when the page is repaired, but it does not purge that record from the table. The table itself has a record limit and if you never clear that table you will lose any new record of a new suspect pages. SQL Server will never clear a "repaired" page from that table, it has to be done manually.

@gbargsley
Copy link
Contributor

@gbargsley gbargsley commented Dec 6, 2017

Create new command to accompany Restore-DbaDatabase page restore parameter.

https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/manage-the-suspect-pages-table-sql-server

@wsmelton
Copy link
Member Author

@wsmelton wsmelton commented Dec 6, 2017

I'm not sure I follow the comment @gbargsley , what command name are you proposing or is this referring to a Clear-DbaSuspectPage ?

@gbargsley
Copy link
Contributor

@gbargsley gbargsley commented Dec 6, 2017

I was creating another issue this morning and when I looked at this issue for reference I saw it was still open. So I put a note from comments from Stuart on Slack. This is for the Clear command I was going to work on. Sorry for confusion, but was just putting a note for my reference.

@wsmelton
Copy link
Member Author

@wsmelton wsmelton commented Sep 30, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.