Showing posts with label order. Show all posts
Showing posts with label order. Show all posts

Sunday, March 11, 2012

Apply PreSP4 fix

Hi,
I need to apply 3 preSP4 fix to SQL server.
Can i aplly all 3 fix and if so, is the order of how i apply them important?
Kind Regards
Michael TroelsenService packs are cumulative... That means you simply install the most
recent service pack and you will be up-to-date... When you download a
service pack, there will always be a readme file, and installation
procedures...
ALWAYS, read the files and follow the instructions... However generally
installing service packs is very easy... Simply calling a bat file...
"Michael Troelsen" <mit@.edbgruppen.dk> wrote in message
news:Ok7vagv6DHA.1804@.TK2MSFTNGP12.phx.gbl...
quote:

> Hi,
> I need to apply 3 preSP4 fix to SQL server.
> Can i aplly all 3 fix and if so, is the order of how i apply them

important?
quote:

> Kind Regards
> Michael Troelsen
>
>
|||Unless the documentation for these fixes specifically mentions being
installed in a certain order you should be safe installing in any order.
Mike Kruchten
"Michael Troelsen" <mit@.edbgruppen.dk> wrote in message
news:Ok7vagv6DHA.1804@.TK2MSFTNGP12.phx.gbl...
quote:

> Hi,
> I need to apply 3 preSP4 fix to SQL server.
> Can i aplly all 3 fix and if so, is the order of how i apply them

important?
quote:

> Kind Regards
> Michael Troelsen
>
>
|||Michael - in normal circumstances you would only install the latest one, but
the answer is to check with whoever gave you the fixes.#
quote:

> I need to apply 3 preSP4 fix to SQL server.
> Can i aplly all 3 fix and if so, is the order of how i apply them importan
t?
> Kind Regards
> Michael Troelsen
>

Neil Pike MVP/MCSE. Protech Computing Ltd
Reply here - no email
SQL FAQ (484 entries) see
http://forumsb.compuserve.com/gvfor...p?SRV=MSDevApps
(faqxxx.zip in lib 7)
or www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
or www.sqlserverfaq.com
or www.mssqlserver.com/faq|||I came to the same conclusion when i started to check the file version.
Thanx
"Neil Pike" <neilpike@.compuserve.com> wrote in message
news:VA.000061bc.001144a7@.compuserve.com...
> Michael - in normal circumstances you would only install the latest one,
but
> the answer is to check with whoever gave you the fixes.#
>
important?
> Neil Pike MVP/MCSE. Protech Computing Ltd
> Reply here - no email
> SQL FAQ (484 entries) see
> http://forumsb.compuserve.com/gvfor...p?SRV=MSDevApps
> (faqxxx.zip in lib 7)
> or www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
> or www.sqlserverfaq.com
> or www.mssqlserver.com/faq
>

Apply PreSP4 fix

Hi,
I need to apply 3 preSP4 fix to SQL server.
Can i aplly all 3 fix and if so, is the order of how i apply them important?
Kind Regards
Michael TroelsenService packs are cumulative... That means you simply install the most
recent service pack and you will be up-to-date... When you download a
service pack, there will always be a readme file, and installation
procedures...
ALWAYS, read the files and follow the instructions... However generally
installing service packs is very easy... Simply calling a bat file...
"Michael Troelsen" <mit@.edbgruppen.dk> wrote in message
news:Ok7vagv6DHA.1804@.TK2MSFTNGP12.phx.gbl...
> Hi,
> I need to apply 3 preSP4 fix to SQL server.
> Can i aplly all 3 fix and if so, is the order of how i apply them
important?
> Kind Regards
> Michael Troelsen
>
>|||Unless the documentation for these fixes specifically mentions being
installed in a certain order you should be safe installing in any order.
Mike Kruchten
"Michael Troelsen" <mit@.edbgruppen.dk> wrote in message
news:Ok7vagv6DHA.1804@.TK2MSFTNGP12.phx.gbl...
> Hi,
> I need to apply 3 preSP4 fix to SQL server.
> Can i aplly all 3 fix and if so, is the order of how i apply them
important?
> Kind Regards
> Michael Troelsen
>
>|||Michael - in normal circumstances you would only install the latest one, but
the answer is to check with whoever gave you the fixes.#
> I need to apply 3 preSP4 fix to SQL server.
> Can i aplly all 3 fix and if so, is the order of how i apply them important?
> Kind Regards
> Michael Troelsen
>
Neil Pike MVP/MCSE. Protech Computing Ltd
Reply here - no email
SQL FAQ (484 entries) see
http://forumsb.compuserve.com/gvforums/UK/default.asp?SRV=MSDevApps
(faqxxx.zip in lib 7)
or www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
or www.sqlserverfaq.com
or www.mssqlserver.com/faq|||I came to the same conclusion when i started to check the file version.
Thanx
"Neil Pike" <neilpike@.compuserve.com> wrote in message
news:VA.000061bc.001144a7@.compuserve.com...
> Michael - in normal circumstances you would only install the latest one,
but
> the answer is to check with whoever gave you the fixes.#
> > I need to apply 3 preSP4 fix to SQL server.
> > Can i aplly all 3 fix and if so, is the order of how i apply them
important?
> >
> > Kind Regards
> > Michael Troelsen
> >
> Neil Pike MVP/MCSE. Protech Computing Ltd
> Reply here - no email
> SQL FAQ (484 entries) see
> http://forumsb.compuserve.com/gvforums/UK/default.asp?SRV=MSDevApps
> (faqxxx.zip in lib 7)
> or www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
> or www.sqlserverfaq.com
> or www.mssqlserver.com/faq
>

Saturday, February 25, 2012

Application log and backuo operations

I'm using Log Shipping in order to update a backup database on SQL Server
2000. I scheduled the transaction log backup every 5 minutes. The problem is
that SQL Server logs an event into the Application Log every time backup is
completed so the Application Log becomes full very quickly.
Is there any way to disable this behaviour ?
Thank you for any suggestions.
Luigi
Hi,
In Enterprise manager -- SQL Server Agent -- Jobs -- Select the Logshipping
task. Double click above that and
select "Notifications"
In that screen "UNCHECK" the Write to windows Application log and clieck
Apply and OK.
Thanks
Hari
MCDBA
"Luigi" <Luigi@.discussions.microsoft.com> wrote in message
news:3ACE4093-DD77-454C-B59C-A0369417D49D@.microsoft.com...
> I'm using Log Shipping in order to update a backup database on SQL Server
> 2000. I scheduled the transaction log backup every 5 minutes. The problem
is
> that SQL Server logs an event into the Application Log every time backup
is
> completed so the Application Log becomes full very quickly.
> Is there any way to disable this behaviour ?
> Thank you for any suggestions.
> Luigi
|||Thank you Hari for your suggestion.
I tried it but it doesn't solve my problem. The problem isn't about the
job's result : the job is set up in order to write to tha application log in
case of error only. It seems instead that it is the BACKUP command that logs
the event: when I launch my job, I find in the application log the same log
that I find when I backup database by Enterprise Maganer's facilities.
Bye
Luigi
"Hari Prasad" wrote:

> Hi,
> In Enterprise manager -- SQL Server Agent -- Jobs -- Select the Logshipping
> task. Double click above that and
> select "Notifications"
> In that screen "UNCHECK" the Write to windows Application log and clieck
> Apply and OK.
> Thanks
> Hari
> MCDBA
>
> "Luigi" <Luigi@.discussions.microsoft.com> wrote in message
> news:3ACE4093-DD77-454C-B59C-A0369417D49D@.microsoft.com...
> is
> is
>
>
|||SQL Server always write these messages to your logs. Even if you define in sysmessages that they shouldn't be
written. I have suggested to MS that SQL Server honors the setting in sysmessages, we'll see if any such
change appears in the future. If you want to communicate such a wish, you can use sqlwish@.microsoft.com.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Luigi" <Luigi@.discussions.microsoft.com> wrote in message
news:07C296BE-FD47-46D1-94A6-669FD6FB9C67@.microsoft.com...[vbcol=seagreen]
> Thank you Hari for your suggestion.
> I tried it but it doesn't solve my problem. The problem isn't about the
> job's result : the job is set up in order to write to tha application log in
> case of error only. It seems instead that it is the BACKUP command that logs
> the event: when I launch my job, I find in the application log the same log
> that I find when I backup database by Enterprise Maganer's facilities.
> Bye
> Luigi
>
> "Hari Prasad" wrote:

Application log and backuo operations

I'm using Log Shipping in order to update a backup database on SQL Server
2000. I scheduled the transaction log backup every 5 minutes. The problem is
that SQL Server logs an event into the Application Log every time backup is
completed so the Application Log becomes full very quickly.
Is there any way to disable this behaviour '
Thank you for any suggestions.
LuigiHi,
In Enterprise manager -- SQL Server Agent -- Jobs -- Select the Logshipping
task. Double click above that and
select "Notifications"
In that screen "UNCHECK" the Write to windows Application log and clieck
Apply and OK.
Thanks
Hari
MCDBA
"Luigi" <Luigi@.discussions.microsoft.com> wrote in message
news:3ACE4093-DD77-454C-B59C-A0369417D49D@.microsoft.com...
> I'm using Log Shipping in order to update a backup database on SQL Server
> 2000. I scheduled the transaction log backup every 5 minutes. The problem
is
> that SQL Server logs an event into the Application Log every time backup
is
> completed so the Application Log becomes full very quickly.
> Is there any way to disable this behaviour '
> Thank you for any suggestions.
> Luigi|||SQL Server always write these messages to your logs. Even if you define in sysmessages that they shouldn't be
written. I have suggested to MS that SQL Server honors the setting in sysmessages, we'll see if any such
change appears in the future. If you want to communicate such a wish, you can use sqlwish@.microsoft.com.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Luigi" <Luigi@.discussions.microsoft.com> wrote in message
news:07C296BE-FD47-46D1-94A6-669FD6FB9C67@.microsoft.com...
> Thank you Hari for your suggestion.
> I tried it but it doesn't solve my problem. The problem isn't about the
> job's result : the job is set up in order to write to tha application log in
> case of error only. It seems instead that it is the BACKUP command that logs
> the event: when I launch my job, I find in the application log the same log
> that I find when I backup database by Enterprise Maganer's facilities.
> Bye
> Luigi
>
> "Hari Prasad" wrote:
> > Hi,
> >
> > In Enterprise manager -- SQL Server Agent -- Jobs -- Select the Logshipping
> > task. Double click above that and
> > select "Notifications"
> >
> > In that screen "UNCHECK" the Write to windows Application log and clieck
> > Apply and OK.
> >
> > Thanks
> > Hari
> > MCDBA
> >
> >
> >
> > "Luigi" <Luigi@.discussions.microsoft.com> wrote in message
> > news:3ACE4093-DD77-454C-B59C-A0369417D49D@.microsoft.com...
> > > I'm using Log Shipping in order to update a backup database on SQL Server
> > > 2000. I scheduled the transaction log backup every 5 minutes. The problem
> > is
> > > that SQL Server logs an event into the Application Log every time backup
> > is
> > > completed so the Application Log becomes full very quickly.
> > >
> > > Is there any way to disable this behaviour '
> > >
> > > Thank you for any suggestions.
> > >
> > > Luigi
> >
> >
> >

Application log and backuo operations

I'm using Log Shipping in order to update a backup database on SQL Server
2000. I scheduled the transaction log backup every 5 minutes. The problem is
that SQL Server logs an event into the Application Log every time backup is
completed so the Application Log becomes full very quickly.
Is there any way to disable this behaviour '
Thank you for any suggestions.
LuigiHi,
In Enterprise manager -- SQL Server Agent -- Jobs -- Select the Logshipping
task. Double click above that and
select "Notifications"
In that screen "UNCHECK" the Write to windows Application log and clieck
Apply and OK.
Thanks
Hari
MCDBA
"Luigi" <Luigi@.discussions.microsoft.com> wrote in message
news:3ACE4093-DD77-454C-B59C-A0369417D49D@.microsoft.com...
> I'm using Log Shipping in order to update a backup database on SQL Server
> 2000. I scheduled the transaction log backup every 5 minutes. The problem
is
> that SQL Server logs an event into the Application Log every time backup
is
> completed so the Application Log becomes full very quickly.
> Is there any way to disable this behaviour '
> Thank you for any suggestions.
> Luigi|||Thank you Hari for your suggestion.
I tried it but it doesn't solve my problem. The problem isn't about the
job's result : the job is set up in order to write to tha application log in
case of error only. It seems instead that it is the BACKUP command that logs
the event: when I launch my job, I find in the application log the same log
that I find when I backup database by Enterprise Maganer's facilities.
Bye
Luigi
"Hari Prasad" wrote:

> Hi,
> In Enterprise manager -- SQL Server Agent -- Jobs -- Select the Logshippin
g
> task. Double click above that and
> select "Notifications"
> In that screen "UNCHECK" the Write to windows Application log and clieck
> Apply and OK.
> Thanks
> Hari
> MCDBA
>
> "Luigi" <Luigi@.discussions.microsoft.com> wrote in message
> news:3ACE4093-DD77-454C-B59C-A0369417D49D@.microsoft.com...
> is
> is
>
>|||SQL Server always write these messages to your logs. Even if you define in s
ysmessages that they shouldn't be
written. I have suggested to MS that SQL Server honors the setting in sysmes
sages, we'll see if any such
change appears in the future. If you want to communicate such a wish, you ca
n use sqlwish@.microsoft.com.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Luigi" <Luigi@.discussions.microsoft.com> wrote in message
news:07C296BE-FD47-46D1-94A6-669FD6FB9C67@.microsoft.com...[vbcol=seagreen]
> Thank you Hari for your suggestion.
> I tried it but it doesn't solve my problem. The problem isn't about the
> job's result : the job is set up in order to write to tha application log
in
> case of error only. It seems instead that it is the BACKUP command that lo
gs
> the event: when I launch my job, I find in the application log the same lo
g
> that I find when I backup database by Enterprise Maganer's facilities.
> Bye
> Luigi
>
> "Hari Prasad" wrote:
>

Application is closed during second synchronization

My Merge Replication was working correctly till New Year.
The initial synchronization is always synchronous (I must have a
database in order to start my application) and the rest of them are
asynchronous. This scenarios was working perfectly.
Now, without making any changes, initial replication (copy of the whole
database) is correctly done, but subsequent replication calls fail, and
fail without giving any error! I've got a catch block where I display a
messagebox with the thrown exception but this code is never reached. An
aplication is completely closed without any error message.
What can be happening? It's really strange and very urgent. I promise
you this code was perfecty working before Christmas.
Ah! I've also tried making a synchronous replication second time, but
same thing occurs.I've deleted the local database, created again the
publication on the server.........
I would really appreciate any help on this. Thanks very much.
Can you successfully run the merge agent from SSMS? If not, is there any
message sent?
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||I've now checked another thing: when I've already got a local database,
second, third, fourth and subsequent synchronizations are correctly
done, and they ar ein asynchronous mode.
The problems is starting the application for the first time, with no
database. Database is correctly downloaded first time, but second time,
my application exits without any error message.
Sorry for my poor SQL Server knowledge, but how do I run the Merge
Agent from Management Studio?
Really strange.......thanks for your help.
|||To start the merge agent in SQL Server 2000, open Enterprise Manager,
Replication Monitor, Expand the publication and on the RHS you'll see the
related agents. Right-clicking on it will allow you to start the agent. In
SSMS (SQL Server 2005) the process is similar, but Replication Monitor is a
separate application that is started by right-clicking the replication
folder.
Also, I proobably need a little more clarification about some of your
descriptions. You mention starting the application when you don't have a
local database. Does your application create a local database and then
create the publication, subscription and then initialize the subscription?
Also, you're using asychronous and synchronous processing - are you
referring to MSMQ, Service Broker or some such mechanism?
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||I've been able to start the Merge Agent from SQL Server 2005 Management
Studio. Agent runs correctly.
Some clarifications:
I use always Merge Replication.
My application initially checks if there is a local database
(downloaded before maybe); if there is, the synchronization is
asynchronous because we have data to play with.
If there is no database, I make a synchronous call with Synchronize()
method and wait. Then, I again have got data to play with. Next calls
will also be asynchronous.
This is the merge replication code I'm using. Really simple:
private void CheckReplicationStatus(object sender, EventArgs e)
{
if (true)
{
try
{
ConfigureReplicationManager();
if (replicationManager !=3D null &&
systemCanReplicate)
{
replicationManager.HostName =3D userId;
// Check if the database file already exists
if
(!System.IO.File.Exists(Constants.DatabaseFilePath ))
{
// Add a new subscripton and create the
local database file
replicationManager.AddSubscription(AddOption.Creat eDatabase);
// La replicaci=F3n inicial es
necesariamente s=EDncrona ya que no existe la BD en local
replicationManager.Synchronize();
replicationManager.Dispose();
}
else
{
// Replicaci=F3n as=EDncrona
IAsyncResult ar =3D
replicationManager.BeginSynchronize(new
AsyncCallback(SyncCompletedCallback), replicationManager);
}
}
else // No ha sido capaz de leer los ficheros de
configuraci=F3n y no ha podido configurar la replicaci=F3n
{
// La idea es ver si la BD existe en el
dispositivo --> Se le deja continuar ejecutando la aplicaci=F3n
// pero se cancela la replicaci=F3n. Pero no hay
manera ya que el path de la BD est=E1 tambi=E9n en los ficheros de
configuraci=F3n
GeneralBehaviour.ShowErrorMessage(Properties.Resou rces.MasterForm_CannotRea=
dConfigurationFiles);
Application.Exit();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToUpper());
replicationManager.Dispose();
GeneralBehaviour.ShowErrorMessage(Properties.Resou rces.MasterForm_InitialSy=
nchronizationFailed);
// TODO: BORRAR LA BD YA QUE NO ES UNA BD OPERATIVA
Application.Exit();
}
}
}
/// <summary>
/// Evento que recoge los resultados de la sincronizaci=F3n
as=EDncrona
/// </summary>
/// <param name=3D"ar"></param>
public void SyncCompletedCallback(IAsyncResult ar)
{
try
{
SqlCeReplication repl =3D
(SqlCeReplication)ar.AsyncState;
replicationManager =3D (SqlCeReplication)ar.AsyncState;
replicationManager.EndSynchronize(ar);
}
catch (SqlCeException exc)
{
// Fallo en la sincronizaci=F3n as=EDncrona --> La
aplicaci=F3n sigue corriendo ya que tenemos BD en local
replicationManager.CancelSynchronize();
}
finally
{
replicationManager.Dispose();
}
}
This is all what I have Paul. Don't know what to do yet! It was working
and I'm spending my second day after a solution for this.
What do you think? Seems SQL Server's fault to me but cannot explain
why only fails second synchronization after first synchronization in
which I download all database.
Thanks for your time. Regards.
|||Hi again Paul,
I've tried to debug but I loose debugger when executing Synchronize()
method for the second time. I'm suffering this problem with the
debugger. It tells me:
"The remote connection to the device has been lost. Please verify the
device connection and restart debugging".
I saw a solution for this error on the internet and although I don't
know if it's related, I installed "Virtual Machine Network Driver for
Microsoft Device Emulator".
But debugger continues failing.
I don't know what else could I do. What frustrating is this situation!
Thanks.
|||If the merge agent can be successfully run in the case of the Synchronous
setup, then it seems to point to an application issue. Sorry, but
unfortunately I'm probably not the best to help in terms of debugging the C#
code (and debugging the debugger itself), so hopefully someone else can
continue the thread. If not, I'd recommend posting this in the C# newsgroup.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||Starting the application without database and debugging, first
synchronization is correctly done. Second one crashes again my
debugger.
Starting the application with the database downloaded in the first try,
first synchronization is again correct. Second crashes again my
debugger.
Thanks Paul for your interest. Don't know exactly how but I suddenly
received just before having lunch this error from the application:
"A call to SQL Server Reconciler failed. Try to resynchronize.; The
Subscriber's schema version information is inconsistent with the
Publisher's schema version information. It is likely that the Publisher
has been restored from a backup whose schema change version is
different from the Subscriber. Rerun the Snapshot agent and
reinitialize the subscriptions. The Publisher and Subscriber schema
guids and version are:
'FFE575BF-5368-41BE-A451-10723451634B',272,'892E72E7-962F-437A-9228-F757FED7ECB9',272
respectively.}"
I've never seen that error before but I understand deleting and
generating again the publication will solve it.
Thanks for your time.
|||Your schema versions do not match. If you reinitialize, it will clean this
up.
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com
"Lonifasiko" <mloichate@.gmail.com> wrote in message
news:1136285094.858729.123150@.g49g2000cwa.googlegr oups.com...
I've been able to start the Merge Agent from SQL Server 2005 Management
Studio. Agent runs correctly.
Some clarifications:
I use always Merge Replication.
My application initially checks if there is a local database
(downloaded before maybe); if there is, the synchronization is
asynchronous because we have data to play with.
If there is no database, I make a synchronous call with Synchronize()
method and wait. Then, I again have got data to play with. Next calls
will also be asynchronous.
This is the merge replication code I'm using. Really simple:
private void CheckReplicationStatus(object sender, EventArgs e)
{
if (true)
{
try
{
ConfigureReplicationManager();
if (replicationManager != null &&
systemCanReplicate)
{
replicationManager.HostName = userId;
// Check if the database file already exists
if
(!System.IO.File.Exists(Constants.DatabaseFilePath ))
{
// Add a new subscripton and create the
local database file
replicationManager.AddSubscription(AddOption.Creat eDatabase);
// La replicacin inicial es
necesariamente sncrona ya que no existe la BD en local
replicationManager.Synchronize();
replicationManager.Dispose();
}
else
{
// Replicacin asncrona
IAsyncResult ar =
replicationManager.BeginSynchronize(new
AsyncCallback(SyncCompletedCallback), replicationManager);
}
}
else // No ha sido capaz de leer los ficheros de
configuracin y no ha podido configurar la replicacin
{
// La idea es ver si la BD existe en el
dispositivo --> Se le deja continuar ejecutando la aplicacin
// pero se cancela la replicacin. Pero no hay
manera ya que el path de la BD est tambin en los ficheros de
configuracin
GeneralBehaviour.ShowErrorMessage(Properties.Resou rces.MasterForm_CannotReadConfigurationFiles);
Application.Exit();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToUpper());
replicationManager.Dispose();
GeneralBehaviour.ShowErrorMessage(Properties.Resou rces.MasterForm_InitialSynchronizationFailed);
// TODO: BORRAR LA BD YA QUE NO ES UNA BD OPERATIVA
Application.Exit();
}
}
}
/// <summary>
/// Evento que recoge los resultados de la sincronizacin
asncrona
/// </summary>
/// <param name="ar"></param>
public void SyncCompletedCallback(IAsyncResult ar)
{
try
{
SqlCeReplication repl =
(SqlCeReplication)ar.AsyncState;
replicationManager = (SqlCeReplication)ar.AsyncState;
replicationManager.EndSynchronize(ar);
}
catch (SqlCeException exc)
{
// Fallo en la sincronizacin asncrona --> La
aplicacin sigue corriendo ya que tenemos BD en local
replicationManager.CancelSynchronize();
}
finally
{
replicationManager.Dispose();
}
}
This is all what I have Paul. Don't know what to do yet! It was working
and I'm spending my second day after a solution for this.
What do you think? Seems SQL Server's fault to me but cannot explain
why only fails second synchronization after first synchronization in
which I download all database.
Thanks for your time. Regards.

Friday, February 24, 2012

Application - document locking

Hi !
I have problem with locking concept in my application (ADO.NET , C#).
Application has several documents which looks like Order.
My question is what and how should I lock those documents.
1.Lock document as a whole (Order + OrderLines) so another user can't work
on this document (pessimistic lock)?
1.1. How to implement this on SQL server ?
2.Should I use optimistic locking on Order and OrderLines ?
3.If I use optimistic locking on OrderLines should I each time update
timestamp of Order
and by each insert, update and read of OrderLine check whether somebody
has changed this Order and/or OrderLine which is both possible ?
Any thoughts are appreciated!"Marek" <marek@.home.puton.cz> wrote in message
news:%23OCPpamIGHA.3192@.TK2MSFTNGP10.phx.gbl...
> Hi !
>
> I have problem with locking concept in my application (ADO.NET , C#).
> Application has several documents which looks like Order.
> My question is what and how should I lock those documents.
>
> 1.Lock document as a whole (Order + OrderLines) so another user can't work
> on this document (pessimistic lock)?
> 1.1. How to implement this on SQL server ?
my advice: forget about #1. what #1 really means? either selecting the data
with (updlock,holdlock) or something similar, and keeping the transaction
open for indefinite amount of time (no, no, no, and no), or setting some
flag, marking that the document is being edited by a client, which is
somewhat better, but still leaves you with the housekeeping problems that
have to be dealt with from the application (and relying on application to
take care of things is generally not a good idea).

> 2.Should I use optimistic locking on Order and OrderLines ?
i would. and i do.

> 3.If I use optimistic locking on OrderLines should I each time update
> timestamp of Order
> and by each insert, update and read of OrderLine check whether somebody
> has changed this Order and/or OrderLine which is both possible ?
a timestamp column will be updated automatically each time data in the row
is updated, you just have to check whether it's value is same as what it was
when the row was read.
it's just my opinion, of course..
dean|||
> a timestamp column will be updated automatically each time data in the row
> is updated, you just have to check whether it's value is same as what it
> was when the row was read.
> it's just my opinion, of course..
> dean
Tnx Dean, but I believe that you answer is over simplified
and does not address all the issues ...
What should happened when orderline is updated ?
should order also be touched (so timestamp can change)
Is this sequence right when updating Orderline ?
1.Get TimeStamp of Order
2. Get TimeStamp of OrderLine
3. User changes orderline
4. Check if Order was changed meanwhile
4. 1 If yes there is a conflict since somebody changed order while I was
updating OrderLine
5. Check if OrderLine was changed
5.1 If yes there is a conflict since somebody changed OrderLine line while I
was updating OrderLine
6. Update OrderLine
7. Touch Order
or there is not need to check for Order Timestamp
when updating OrderLine in this case|||If you acquire locks in the correct order and hold them until the end of the
transaction, no other user will be able to change any rows that you have
locked until the transaction is either committed or rolled back.
ML
http://milambda.blogspot.com/|||hi, marek
yes, it was somewhat simplified, i agree. the actual implementation depends
on the actual business requirements (eg, is it ok that two people work with
different lineitems of the same document?), so this sequence could be
right - provided that everything from (and including) #4 is isolated inside
a transaction.
dean
"Marek" <marek@.home.puton.cz> wrote in message
news:uQlLHnnIGHA.3060@.TK2MSFTNGP10.phx.gbl...
>
> Tnx Dean, but I believe that you answer is over simplified
> and does not address all the issues ...
> What should happened when orderline is updated ?
> should order also be touched (so timestamp can change)
> Is this sequence right when updating Orderline ?
> 1.Get TimeStamp of Order
> 2. Get TimeStamp of OrderLine
> 3. User changes orderline
> 4. Check if Order was changed meanwhile
> 4. 1 If yes there is a conflict since somebody changed order while I was
> updating OrderLine
> 5. Check if OrderLine was changed
> 5.1 If yes there is a conflict since somebody changed OrderLine line while
> I was updating OrderLine
> 6. Update OrderLine
> 7. Touch Order
> or there is not need to check for Order Timestamp
> when updating OrderLine in this case
>
>|||Well it's interesting how would you solve the problem
when two people must not work with 2 different Orderlines
of the same Order ? Should we use pessimistic locking than ?
Another question that arises when considering scenario below is
how many roundtrips to SQL requires such a solution ?
Steps 1,2 - one roundtrip
Steps 4,5 - one roundtrip
Steps 6,7 - one roundtrip
Can this be smaller number than 3 ?
> yes, it was somewhat simplified, i agree. the actual implementation
> depends on the actual business requirements (eg, is it ok that two people
> work with different lineitems of the same document?), so this sequence
> could be right - provided that everything from (and including) #4 is
> isolated inside a transaction.
>|||not more than 2 roundtrips - 1&2 is one, 4-7 the other one, inside a stored
procedure, inside a transaction.
dean
"Marek" <marek@.home.puton.cz> wrote in message
news:OIqObNoIGHA.524@.TK2MSFTNGP09.phx.gbl...
> Well it's interesting how would you solve the problem
> when two people must not work with 2 different Orderlines
> of the same Order ? Should we use pessimistic locking than ?
> Another question that arises when considering scenario below is
> how many roundtrips to SQL requires such a solution ?
> Steps 1,2 - one roundtrip
> Steps 4,5 - one roundtrip
> Steps 6,7 - one roundtrip
> Can this be smaller number than 3 ?
>
>
>|||Tnx. Dean
That looks like a reasonable solution
with minimum overhead on SQL server side.
And what would be theoretical scenario:
1. when two people must not work with 2 different Orderlines of the same
order
2. two people must work not with the same Order at all ?
Does this require pessimistic lock and an open connection during
order/orderline update or is there better simpler solution ?
I have two solutions on my mind:
1. Lock the whole Order and child Orderlines with hold lock so nobody
can update those records.
2. Create LockingTable (RecordId, UserId) and hold connection open
on this record in LockingTable so if program crashes
SQL server will release lock. Before reading record With 'SELECT (NOLOCK)'
read
wheather record is locked and if it is tell the user who locks the record.
But both solutions require open connection ?
I'm I missing something ?
"Dean" <dvitner@.nospam.gmail.com> wrote in message
news:uxNdmVoIGHA.1836@.TK2MSFTNGP11.phx.gbl...
> not more than 2 roundtrips - 1&2 is one, 4-7 the other one, inside a
> stored procedure, inside a transaction.
> dean
> "Marek" <marek@.home.puton.cz> wrote in message
> news:OIqObNoIGHA.524@.TK2MSFTNGP09.phx.gbl...
>|||hi again,
as i see it, this whole optimistic vs pessimistic thing is really a business
problem. in most cases, unless you're dealing with some very chaotic
organization, it is well known who can do what with what data. it is not
unusual to have an owner for the document, and only that person is permitted
to make updates to the specific document. this type of scenario (involving
update conflicts) is rather unlikely in the real world, imo. sometimes it's
practically impossible, sometimes it's desirable, even required (why not let
several people do the data entry on an inventory list?). to answer the
question 'how to deal with it?' is really up to your customers. ask them, is
it possible at all? how often could it happen? how severe will the
consequences be? most of them, in my experience, could live with an update
conflict here and there - as long as you can tell them what happened, and
who was competing with them. auditing is here much more important than
locking.
technically speaking, would you really want to let the user opet a
transaction, select the data and place and hold update lock on the data,
then keep the data locked for nobody knows how long (he might go to lunch,
or go home or whatever - you have no control over it), and eventually at
some point in time decide to end the transaction, with or without any
change? first of all, transactions should be short-lived - started as late
as possible, and ended as soon as possible. they eat up resorces on server,
and keep others from accessing data. i can't think of a real-world situation
that would justify such a scenario.
you have come to a rather good practical solution yourself (in your previous
post) - why not use it?
dean
"Marek" <marek@.home.puton.cz> wrote in message
news:eXoRwooIGHA.3144@.TK2MSFTNGP11.phx.gbl...
> Tnx. Dean
> That looks like a reasonable solution
> with minimum overhead on SQL server side.
> And what would be theoretical scenario:
> 1. when two people must not work with 2 different Orderlines of the same
> order
> 2. two people must work not with the same Order at all ?
> Does this require pessimistic lock and an open connection during
> order/orderline update or is there better simpler solution ?
> I have two solutions on my mind:
> 1. Lock the whole Order and child Orderlines with hold lock so nobody
> can update those records.
> 2. Create LockingTable (RecordId, UserId) and hold connection open
> on this record in LockingTable so if program crashes
> SQL server will release lock. Before reading record With 'SELECT (NOLOCK)'
> read
> wheather record is locked and if it is tell the user who locks the record.
> But both solutions require open connection ?
> I'm I missing something ?
>
>
> "Dean" <dvitner@.nospam.gmail.com> wrote in message
> news:uxNdmVoIGHA.1836@.TK2MSFTNGP11.phx.gbl...
>|||Thanks Dean !
I don't have such situation , but I was just thinking aloud.
Currently in my firm there is an old proprietary system which uses
pessimistic
locking and it works fine, so I was thinking how this can be implemented on
SQL server.
Since the whole architecture of ADO.NET does not encourage pessimistic
locking
and there is no business need to support it I will definitely use solution
to that we came up in previous posts. Thanky you again for a thoughtful
posts
that have broadened my "data access" sights !
"Dean" <dvitner@.nospam.gmail.com> wrote in message
news:unvH%23hqIGHA.2708@.tk2msftngp13.phx.gbl...
> hi again,
> as i see it, this whole optimistic vs pessimistic thing is really a
> business problem. in most cases, unless you're dealing with some very
> chaotic organization, it is well known who can do what with what data. it
> is not unusual to have an owner for the document, and only that person is
> permitted to make updates to the specific document. this type of scenario
> (involving update conflicts) is rather unlikely in the real world, imo.
> sometimes it's practically impossible, sometimes it's desirable, even
> required (why not let several people do the data entry on an inventory
> list?). to answer the question 'how to deal with it?' is really up to your
> customers. ask them, is it possible at all? how often could it happen? how
> severe will the consequences be? most of them, in my experience, could
> live with an update conflict here and there - as long as you can tell them
> what happened, and who was competing with them. auditing is here much more
> important than locking.
> technically speaking, would you really want to let the user opet a
> transaction, select the data and place and hold update lock on the data,
> then keep the data locked for nobody knows how long (he might go to lunch,
> or go home or whatever - you have no control over it), and eventually at
> some point in time decide to end the transaction, with or without any
> change? first of all, transactions should be short-lived - started as late
> as possible, and ended as soon as possible. they eat up resorces on
> server, and keep others from accessing data. i can't think of a real-world
> situation that would justify such a scenario.
> you have come to a rather good practical solution yourself (in your
> previous post) - why not use it?
> dean
> "Marek" <marek@.home.puton.cz> wrote in message
> news:eXoRwooIGHA.3144@.TK2MSFTNGP11.phx.gbl...
>