Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8254559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:13:57+00:00 2026-06-08T01:13:57+00:00

It is required to shut down the system I’m working on before the database

  • 0

It is required to shut down the system I’m working on before the database gets restored. If a customer does not do this, he may run into serious problems, because the in-memory state of the application server does not match the database. It may take some time until the corrupt database causes errors and the system stops working and the database is unusable.

So I try to detect this situation and avoid the problem.

  • The application server does not necessarily keep a connection alive, so single user mode and stuff like this most probably wont help.
  • I don’t care if the restore would fail or the server would shut down or whatever. It just shouldn’t ignore it.
  • the database may be restored by any sql server tool on any machine. I can’t rely on my own tools.

Did anyone already solve such a problem?

I’m using SQL Server 2005 and above, .NET (C#), SMO.


Edit:

Because of some misconceptions and discussions about application design, I need to explain where the problem comes from.

The Hi-Lo generator: The application uses NHibernate, which has a cache of Hi-Values of the Hi-Lo id generator. The Hi-Values are read from the database and allows the application to generate a specific number of primary keys until it requires to go back to the database and get another range of numbers. The Hi-Values stored in the database are only incremented, but never decremented (unless when a older version of the database is restored). This is the concept of the Hi-Lo generator, it is neither invented nor implemented by myself.

Caches: In caches, primary keys are used to identify records in the database. Primary keys do never change in normal use of the database. In case of a restore, the primary keys do not identify the same record anymore and the caches are just plain wrong. It can’t even detect this. It might result, for instance, in setting wrong foreign keys in new records.

A DB restore can’t be compared to any other normal use of the database. A restore breaks all the rules of data handling.

I guess that many applications keep connections open while they are running, making restore impossible. Most other applications would probably just crash when the database is restored and it tries to access the database afterwards. In my case, it may keep running for awhile, which is a problem.

I guess that most people don’t even try to restore the database when the application is running.

There is a theoretical, an in my case proven, risk that something is going completely wrong when a database is restored while the application is still in memory. I don’t want to be told that this is not a problem at all, just because most applications do not handle it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:13:59+00:00Added an answer on June 8, 2026 at 1:13 am

    I didn’t get a useful answer, so I assume that there is no general solution to this problem.

    I only see two ways to solve it:

    • Executing a query at the begin of every transaction to see if the database is another one. E.g. the last time when it had been restored as described here. This may hurt performance and may also be a permissions problem
    • I open a “keep-alive” connection to the database which avoids that the database is restored. This may be much easier to implement. It is not very nice, because it wastes a connection.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We use @Constraint.Required to validate the fields of our forms, and this generates a
What is the NSFormat required for a string like this? Fri, 15 Jun 2012
I am required to count all the instances of quotes in the system based
I have deleted some .h and .m libraries which were not required in my
required( dependency-expression ) They give an example of required: #other:checked but I want my
Advice required on architecting module I have a PORT Listener that listens to a
Code required to append list (anotherList) to item (id -= l1) of second list
I am required to write a C++ application to run on an embedded Linux
// No overrides required .. let CLR take care of equal and hashcode. Class
i have given required permission : <uses-permission android:name=android.permission.WRITE_EXTERNAL_STORAGE /> hard-coded the path as /sdcard/filename

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.