Category: Blog

  • Backups and Consistency

    I wrote about transactional consistency recently. Why do we need this?

    Imagine that I have an orders table and an ordersdetail table in my database. The orders table has the order header (date, customer, etc) and the detail table includes information about the items purchased (product, qty, price). Let’s say my orders table has 10 orders and my detail table has 5 items for each order for a total of 50 rows in the detail table.

    If I want a backup that is consistent, I need to have all of the orders and details included in the backup. I don’t want partial orders, so all my inserts for orders and details are included in a transaction. That means my backup needs to contain a complete, new order, or no new order at all. Anything else wouldn’t be consistent.

    The backup process you choose needs to account for this. It cannot include partial orders from a transaction inside of it. Could that happen?

    Sure, and let’s see how. Backups proceed linearly and it takes time for them to complete. Imagine that I have a process that starts backing up my Orders table. It reads orders 1 and 2.

    While this is happening, someone inserts a new order, #6, into the system. If my backup system is reading pages, it might continue through orders 3-6 and then start on details. Imagine now the user rolls back the new order. When my backup completes, it will include (and restore) an order #6. That could be a problem.

    The other problem could be that the backup process gets to the details table and starts backing up the first 5 details from order#1. While this is happening, a user inserts a new order and order details in a transaction (order #7), and it completes. The backup process moves through the details table and gets all the details, including the new detail records inserted during the backup. However the orders table has already been backed up. The restore will include details for order #7, but not the header (Orders table).

    That’s bad.

    Don’t use file backups, no open file managers, no exports, no BACPACs as backups for your data. You might have serious data issues on restore, which get worse as your workload is busier on the system.

    Make sure that your backups are transactionally consistent. Don’t export, don’t use open file managers, don’t use anything that doesn’t respect transactions. The native SQL Server backup process does this. If you want a few other features, my employer makes SQL Backup Pro, which also respects transactions.

  • Learn about Database Deployment in DC

    SQL in the City is coming to the DC area in a few weeks with a seminar on the Stairway to Database Deployment. Both Grant Fritchey and I are traveling to the Washington DC area to deliver a half day, free seminar event on Friday, December 6, 2013. We are likely going to be in the Chevy Chase, MD side of DC that afternoon, but I don’t have a location right now.

    If you are in the area, and want to see our vision of how to streamline your database development and deployment and make it run smoother, register today. It’s free, it’s a half day, and afterwards Grant and I will be chatting with you at a happy hour to talk shop, deployment, anything you want.

    The seminar is three sessions. I have been presenting the first 2, and Grant the third. The sessions build on each other and are the following:

    • Team-based Development with Version Control
    • Automated Database Build and Test
    • Best Practices for Database Deployment

    I’ll also be at SQL Saturday #233 – Washington, DC on Saturday, December 7, 2013. I think I have one session, and I may leave early as I have family in the area, but I’ll be there all morning and happy to chat with you, shake hands, or even just say hi.

    If you can attend, please register for SQL in the City or SQL Saturday #233. Both events are free, but we’d like to know who’s coming so we can plan.

  • More Vacation

    As I try to recharge and relax, I’m taking today and tomorrow off. Just a quick note that I’m trying to live up to my advice and get away from work when I can.

  • Powershell in a Month – Day 2, Help

    This is part of my Powershell Challenge, to learn more about Powerhsell (PoSh) using the Learn Windows Powershell 3 in a Month of Lunches book by Don Jones.

    Today was Chapter 3, Using the Help System. Another not-so-exciting topic, but one that does matter. There are a ton of commands to learn and use in PoSh and being able to get help on them is important if you are to develop code with any level of speed. Note I said code. This is scripting, it’s interactive, but it’s code. Whether you run it once or save it and schedule executions every minute, it’s code.

    The first point in the chapter is to RTFM, or “read the friendly manual”. The authors emphasize that using Google instead of help means you’re copying code, not learning about the code, and potentially stunting your development or even wrecking your production system with commands you don’t understand. As much as I love Google, I can understand the point here.

    One of the first things the chapter does is ask you to update help. However that didn’t work for me:

    Posh_006

    The book doesn’t talk about the CLI v the ISE, which is the problem. I found a post on MSDN that noted this works from Powershell, but not the Powershell ISE.  Once I went to the CLI, it worked.

    Posh_005

    I used to do UNIX work, and was forever typing “Man xxx” to learn about xxx. MAN is a wrapper here, as is “help” for the get-help command. I played around with some get-help stuff, using wildcards and tab completion. Both of which are handy. I can definitely see that learning to use help and tab is important.

    The rest of the chapter brings out various ways in which you can use help, including getting more details, getting examples, and going to the online pages, which are more up to date than your local copy might be. All good tricks to getting going with PoSh. Lots of example commands showing how to get help, and I ran most of these.

    The chapter was boring, but at the end when I got to the lab, I was surprised how little I know. As I tried to go through the lab questions, I wasn’t sure what was working and what wasn’t. I didn’t know if I was actually running the right commands, since things like “help *array*” worked. There are answers you can download from the morelunches.com site, and once I did that, I was able to check my results, and get help on a few items I wasn’t sure about. 

    I was surprised that I learned a few things, and I can definitely see that working with help is both important, and cumbersome. For example, the scrolling isn’t smooth in the ISE and the MORE piping from the HELP wrapper doesn’t work. Definitely something to practice on as I move through the book.