service dependency on a *specific* sql server database

M

matteo

Hello all,
I've written a windows service , set a dependency on Sql Server
service and set the service to Automatic start.
The problem is that my service is still failing to start because it's
true tha it now waits for Sql Server to have started, but the database
it tries to connect to is still not ready.
It seems like Sql Server is announcing it's ready for connection even
if it hasn't still actually started up the databases it handles.

Here's a dump from the sql server log in chronological order:
1. SQL Server is now ready for client connections.
2. Starting up database 'tempdb'.
3. Login failed for user 'DOMDIGI\Mazzotti'. Reason: Failed to open
the explicitly specified database. [CLIENT: <local machine>]
4. Starting up database 'msdb'.
5. Starting up database 'ByAdv' --> this is the database the service
is trying to connect to.

As you can see, the service is attempting a connection well before the
database is ready.
How can I set a dependency on this specific database and not just on
the Sql Server service ?

The OS is Windows Server 2003, so delay start isn't available.

Thank you in advance
 
A

Arne Vajhøj

I've written a windows service , set a dependency on Sql Server
service and set the service to Automatic start.
The problem is that my service is still failing to start because it's
true tha it now waits for Sql Server to have started, but the database
it tries to connect to is still not ready.
It seems like Sql Server is announcing it's ready for connection even
if it hasn't still actually started up the databases it handles.

Here's a dump from the sql server log in chronological order:
1. SQL Server is now ready for client connections.
2. Starting up database 'tempdb'.
3. Login failed for user 'DOMDIGI\Mazzotti'. Reason: Failed to open
the explicitly specified database. [CLIENT:<local machine>]
4. Starting up database 'msdb'.
5. Starting up database 'ByAdv' --> this is the database the service
is trying to connect to.

As you can see, the service is attempting a connection well before the
database is ready.
How can I set a dependency on this specific database and not just on
the Sql Server service ?

The OS is Windows Server 2003, so delay start isn't available.

What about the pragmatic solution of making the service
retry a couple of times with N seconds interval before
giving up?

Arne
 
M

matteo

I've written a windows service , set a dependency on Sql Server
service and set the service to Automatic start.
The problem is that my service is still failing to start because it's
true tha it now waits for Sql Server to have started, but the database
it tries to connect to is still not ready.
It seems like Sql Server is announcing it's ready for connection even
if it hasn't still actually started up the databases it handles.
Here's a dump from the sql server log in chronological order:
1. SQL Server is now ready for client connections.
2. Starting up database 'tempdb'.
3. Login failed for user 'DOMDIGI\Mazzotti'. Reason: Failed to open
the explicitly specified database. [CLIENT:<local machine>]
4. Starting up database 'msdb'.
5. Starting up database 'ByAdv'   -->  this is the database the service
is trying to connect to.
As you can see, the service is attempting a connection well before the
database is ready.
How can I set a dependency on this specific database and not just on
the Sql Server service ?
The OS is Windows Server 2003, so delay start isn't available.

What about the pragmatic solution of making the service
retry a couple of times with N seconds interval before
giving up?

Arne- Nascondi testo citato

- Mostra testo citato -

Yeah, I thought about that, but I was wondering if there was a cleaner
solution
 
J

Jeff Johnson

Yeah, I thought about that, but I was wondering if there was a
cleaner solution

I think something that tends to separate veterans for new programmers is
that the veterans realize that a good chunk of programming isn't
particularly "clean," that is, it often gets things done in a way that makes
you think "That's very inelegant."

(Not that I'm accusing you of being a n00B or anything; it's just been my
observation that generally the people who feel that every situation should
have some graceful solution are those who haven't been programming long
enough to get over that preconception.)
 
A

Arne Vajhøj

I've written a windows service , set a dependency on Sql Server
service and set the service to Automatic start.
The problem is that my service is still failing to start because it's
true tha it now waits for Sql Server to have started, but the database
it tries to connect to is still not ready.
It seems like Sql Server is announcing it's ready for connection even
if it hasn't still actually started up the databases it handles.
Here's a dump from the sql server log in chronological order:
1. SQL Server is now ready for client connections.
2. Starting up database 'tempdb'.
3. Login failed for user 'DOMDIGI\Mazzotti'. Reason: Failed to open
the explicitly specified database. [CLIENT:<local machine>]
4. Starting up database 'msdb'.
5. Starting up database 'ByAdv' --> this is the database the service
is trying to connect to.
As you can see, the service is attempting a connection well before the
database is ready.
How can I set a dependency on this specific database and not just on
the Sql Server service ?
The OS is Windows Server 2003, so delay start isn't available.

What about the pragmatic solution of making the service
retry a couple of times with N seconds interval before
giving up?
Yeah, I thought about that, but I was wondering if there was a cleaner
solution

There could be.

But how much time do you want to spend looking for it?

And it seems likely that a more clean solution will
actually be more difficult to maintain than the simple
code.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top