<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Drizzle Replication &#8211; The Transaction Log</title>
	<atom:link href="http://www.joinfu.com/2009/10/drizzle-replication-the-transaction-log/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joinfu.com/2009/10/drizzle-replication-the-transaction-log/</link>
	<description>the art of sql</description>
	<lastBuildDate>Mon, 23 Jan 2012 21:05:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Jay Pipes</title>
		<link>http://www.joinfu.com/2009/10/drizzle-replication-the-transaction-log/comment-page-1/#comment-189485</link>
		<dc:creator>Jay Pipes</dc:creator>
		<pubDate>Thu, 29 Oct 2009 14:58:55 +0000</pubDate>
		<guid isPermaLink="false">http://joinfu.com/2009/10/drizzle-replication-the-transaction-log#comment-189485</guid>
		<description>You got it!  The key is the call to pwrite() (see line 83 above).

pwrite() is a standard POSIX system call that is similar to write() but allows the caller to write a supplied buffer of a supplied size to an exact offset in a file.

Here is the doc on pwrite() and write():

http://www.opengroup.org/onlinepubs/000095399/functions/write.html

Cheers!

Jay</description>
		<content:encoded><![CDATA[<p>You got it!  The key is the call to pwrite() (see line 83 above).</p>
<p>pwrite() is a standard POSIX system call that is similar to write() but allows the caller to write a supplied buffer of a supplied size to an exact offset in a file.</p>
<p>Here is the doc on pwrite() and write():</p>
<p><a href="http://www.opengroup.org/onlinepubs/000095399/functions/write.html" rel="nofollow">http://www.opengroup.org/onlinepubs/000095399/functions/write.html</a></p>
<p>Cheers!</p>
<p>Jay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jobin Augustine</title>
		<link>http://www.joinfu.com/2009/10/drizzle-replication-the-transaction-log/comment-page-1/#comment-189484</link>
		<dc:creator>Jobin Augustine</dc:creator>
		<pubDate>Thu, 29 Oct 2009 14:49:56 +0000</pubDate>
		<guid isPermaLink="false">http://joinfu.com/2009/10/drizzle-replication-the-transaction-log#comment-189484</guid>
		<description>Beautiful idea. :)
carve out enough space for the current thread.
leave the other threads to carve out what they want.
..beautiful..beautiful.
threads need not wait for other threads to complete the writing. parallel writes can happen to log. am i right?

replication is going to Rock!</description>
		<content:encoded><![CDATA[<p>Beautiful idea. <img src='http://www.joinfu.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
carve out enough space for the current thread.<br />
leave the other threads to carve out what they want.<br />
..beautiful..beautiful.<br />
threads need not wait for other threads to complete the writing. parallel writes can happen to log. am i right?</p>
<p>replication is going to Rock!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay Pipes</title>
		<link>http://www.joinfu.com/2009/10/drizzle-replication-the-transaction-log/comment-page-1/#comment-189480</link>
		<dc:creator>Jay Pipes</dc:creator>
		<pubDate>Thu, 29 Oct 2009 13:09:12 +0000</pubDate>
		<guid isPermaLink="false">http://joinfu.com/2009/10/drizzle-replication-the-transaction-log#comment-189480</guid>
		<description>Hi Jobin!

First of all, there aren&#039;t any stupid questions. :)  All of this code is extremely new!

So, on line 41:

cur_offset-= static_cast&lt;off_t&gt;((total_envelope_length));

You are correct that we are recalculating the original offset there.  The reason we do this is to &quot;cut out&quot; a chunk of the log file that we will use for writing the current transaction message.  

Because TransactionLog::apply() is code that is run in a threaded server, the variables of the TransactionLog such as the log_offset variable must be protected against changes from another thread&#039;s execution of the TransactionLog::apply() method.

The log_offset variable is of type drizzled::atomic&lt;off_t&gt;.  This means that it&#039;s contents follow the  atomic&lt;&gt; API templates implemented in /drizzled/atomic/.  This template provides methods which ensure synchronized writes of a variable&#039;s contents in a threaded environment.  The atomci&lt;&gt;.fetch_and_add() method atomically increments a variable&#039;s contents and returns the contents of the variable.

On line 35:

cur_offset= log_offset.fetch_and_add(static_cast&lt;off_t&gt;(total_envelope_length));

what we are doing is carving out a chunk of space in the log file long enough to write our complete log entry.  We &quot;carve&quot; this chunk out by simply atomically incrementing the log_offset.  Once incremented, the new log_offset value is returned from fetch_and_add(), and we must therefore subtract the length of the transaction message we will write in order to return to the exact offset into the transaction log that we will write into.

Hope the above makes sense!

Cheers!

Jay</description>
		<content:encoded><![CDATA[<p>Hi Jobin!</p>
<p>First of all, there aren&#8217;t any stupid questions. <img src='http://www.joinfu.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   All of this code is extremely new!</p>
<p>So, on line 41:</p>
<p>cur_offset-= static_cast<off_t>((total_envelope_length));</p>
<p>You are correct that we are recalculating the original offset there.  The reason we do this is to &#8220;cut out&#8221; a chunk of the log file that we will use for writing the current transaction message.  </p>
<p>Because TransactionLog::apply() is code that is run in a threaded server, the variables of the TransactionLog such as the log_offset variable must be protected against changes from another thread&#8217;s execution of the TransactionLog::apply() method.</p>
<p>The log_offset variable is of type drizzled::atomic</off_t><off_t>.  This means that it&#8217;s contents follow the  atomic<> API templates implemented in /drizzled/atomic/.  This template provides methods which ensure synchronized writes of a variable&#8217;s contents in a threaded environment.  The atomci<>.fetch_and_add() method atomically increments a variable&#8217;s contents and returns the contents of the variable.</p>
<p>On line 35:</p>
<p>cur_offset= log_offset.fetch_and_add(static_cast</off_t><off_t>(total_envelope_length));</p>
<p>what we are doing is carving out a chunk of space in the log file long enough to write our complete log entry.  We &#8220;carve&#8221; this chunk out by simply atomically incrementing the log_offset.  Once incremented, the new log_offset value is returned from fetch_and_add(), and we must therefore subtract the length of the transaction message we will write in order to return to the exact offset into the transaction log that we will write into.</p>
<p>Hope the above makes sense!</p>
<p>Cheers!</p>
<p>Jay</off_t></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jobin Augustine</title>
		<link>http://www.joinfu.com/2009/10/drizzle-replication-the-transaction-log/comment-page-1/#comment-189465</link>
		<dc:creator>Jobin Augustine</dc:creator>
		<pubDate>Thu, 29 Oct 2009 04:52:37 +0000</pubDate>
		<guid isPermaLink="false">http://joinfu.com/2009/10/drizzle-replication-the-transaction-log#comment-189465</guid>
		<description>Very much detailed and explanation article.  Thank you.

sorry if i am coming with stupid points.
in TransactionLog::apply line no 41
it looks like offset is moving forward and then calculating and moving backward. is it something which can be avoided?

as you said the dynamic allocation is an issue.
anyway writing need to be serial. so what is the possibility of singleton for write operation?

Thank you,
Jobin.</description>
		<content:encoded><![CDATA[<p>Very much detailed and explanation article.  Thank you.</p>
<p>sorry if i am coming with stupid points.<br />
in TransactionLog::apply line no 41<br />
it looks like offset is moving forward and then calculating and moving backward. is it something which can be avoided?</p>
<p>as you said the dynamic allocation is an issue.<br />
anyway writing need to be serial. so what is the possibility of singleton for write operation?</p>
<p>Thank you,<br />
Jobin.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

