Hello.

On Fri 2002-12-06 at 16:13:54 -0600, [EMAIL PROTECTED] wrote:
> 
> First off, we are using Innodb tables on version 3.23.53a-max.
> 
> If the command STOP SLAVE is issued in the middle of the following type of
> transaction:
> 
> set autocommit = 0;
> update...;
> update...;
> update...;
> commit;
>  
> does it roll back the current transaction or wait for it to complete?

Just to be sure to talk about the same thing: the master logs
transactions only after they are commited successfully. So the slave
will never see a transaction which is not completely finished on the
master. So what is left is the question how the slave handles this
case.

I did not find anything concrete in the documentation (of v4.0.6), so
I decided to dig in the source a bit (v3.23.46).

STOP SLAVE sets a flag that hints that the slave thread should stop.
The slave threads polls this flag quite often, several times while
processing one query (I mean query, not transaction). If it sees the
flag, the thread cleans up and exits.

The C++ destructor of the class associated with each thread calls
rollback in the according (table) handler.

In short, rollback is handled correctly with replication. The question
that is left is whether the transaction boundaries are transferred
correctly. And that is not the case, AFAICS. Although, on first
glance, it looks not too hard to implement (simply adding a
BEGIN/COMMIT pair before it is written to the log should work, I
think).

In short, it seems the slave thread effectively runs in auto-commit
mode which is not what you want.

I found a somewhat old post by Heikki (the InnoDB deveoper) which
basically says the same:

  http://lists.mysql.com/cgi-ez/ezmlm-cgi?1:mss:79650

Another point is, that there is no mechanism in the source, yet, which
would reset the replication position back to BEGIN, in case of
rollback, even if the BEGIN/COMMIT would be transferred.

> Or does it, heaven forbid, just stop in the middle of the
> transaction?

Yes and no. Yes, looks like it will not honor the original transaction
boundaries. No, it will only stop after the current command is
properly executed or rolled back.

HTH,

        Benjamin.


-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to