You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by Sergey Maslyakov <ev...@gmail.com> on 2013/07/08 19:03:41 UTC

Taking two snapshots at the same time

>From looking at the 3.4.5 code, it seems like
ZooKeeperServer.takeSnapshot() method does not have protection against
being invoked twice by different threads. There is some protection against
spawning two snapshot threads from SyncRequestProcessor.run() but this is
just about it.

Is there any inherent danger in having two ZooKeeperServer.takeSnapshot()
overlapping their execution in time? Is it a thread to data integrity or is
it just a possible performance issue?

I'm thinking of adding a new four-letter command to force a snapshot
creation by a command from outside before snapCount threshold is reached.
Is it safe to invoke ZooKeeperServer.takeSnapshot() from a four-word
command handler or does it need to be submitted as a Request object into
the pipeline of Request Processors?


Regards,
/Sergey

Re: Taking two snapshots at the same time

Posted by Thawan Kooburat <th...@fb.com>.
I just add a new 4 letter command (snap).  This will cause the server to
take snapshot if txn count (since last snapshot) is below configurable
threshold (default 1000).

We used this during our (rolling) push process to make the server come
back faster after restart.

-- 
Thawan Kooburat





On 7/8/13 2:31 PM, "Flavio Junqueira" <fp...@yahoo.com> wrote:

>Sergey proposed a few approaches. Could you tells me how you implement
>it, Thawan, please?
>
>-Flavio
>
>On Jul 8, 2013, at 10:39 PM, Thawan Kooburat <th...@fb.com> wrote:
>
>> I have this functionality in our internal branch.
>> 
>> I can post the patch but it is likely to conflict with ZOOKEEPER-1346,
>>so
>> it will be good to know the timeline of that patch.
>> 
>> 
>> -- 
>> Thawan Kooburat
>> 
>> 
>> 
>> 
>> 
>> On 7/8/13 11:48 AM, "Sergey Maslyakov" <ev...@gmail.com> wrote:
>> 
>>> I think I'd answer my own question. Apparently, if lastZxid does not
>>> change
>>> between two takeSnapshot() calls, they both will try to write into the
>>> same
>>> file. This is likely to explode when you try to read this snapshot
>>>back...
>>> So, the protection is needed.
>>> 
>>> 
>>> /Sergey
>>> 
>>> 
>>> On Mon, Jul 8, 2013 at 12:03 PM, Sergey Maslyakov <ev...@gmail.com>
>>> wrote:
>>> 
>>>> From looking at the 3.4.5 code, it seems like
>>>> ZooKeeperServer.takeSnapshot() method does not have protection against
>>>> being invoked twice by different threads. There is some protection
>>>> against
>>>> spawning two snapshot threads from SyncRequestProcessor.run() but this
>>>> is
>>>> just about it.
>>>> 
>>>> Is there any inherent danger in having two
>>>> ZooKeeperServer.takeSnapshot()
>>>> overlapping their execution in time? Is it a thread to data integrity
>>>> or is
>>>> it just a possible performance issue?
>>>> 
>>>> I'm thinking of adding a new four-letter command to force a snapshot
>>>> creation by a command from outside before snapCount threshold is
>>>> reached.
>>>> Is it safe to invoke ZooKeeperServer.takeSnapshot() from a four-word
>>>> command handler or does it need to be submitted as a Request object
>>>>into
>>>> the pipeline of Request Processors?
>>>> 
>>>> 
>>>> Regards,
>>>> /Sergey
>>>> 
>> 
>


Re: Taking two snapshots at the same time

Posted by Flavio Junqueira <fp...@yahoo.com>.
Sergey proposed a few approaches. Could you tells me how you implement it, Thawan, please?

-Flavio

On Jul 8, 2013, at 10:39 PM, Thawan Kooburat <th...@fb.com> wrote:

> I have this functionality in our internal branch.
> 
> I can post the patch but it is likely to conflict with ZOOKEEPER-1346, so
> it will be good to know the timeline of that patch.
> 
> 
> -- 
> Thawan Kooburat
> 
> 
> 
> 
> 
> On 7/8/13 11:48 AM, "Sergey Maslyakov" <ev...@gmail.com> wrote:
> 
>> I think I'd answer my own question. Apparently, if lastZxid does not
>> change
>> between two takeSnapshot() calls, they both will try to write into the
>> same
>> file. This is likely to explode when you try to read this snapshot back...
>> So, the protection is needed.
>> 
>> 
>> /Sergey
>> 
>> 
>> On Mon, Jul 8, 2013 at 12:03 PM, Sergey Maslyakov <ev...@gmail.com>
>> wrote:
>> 
>>> From looking at the 3.4.5 code, it seems like
>>> ZooKeeperServer.takeSnapshot() method does not have protection against
>>> being invoked twice by different threads. There is some protection
>>> against
>>> spawning two snapshot threads from SyncRequestProcessor.run() but this
>>> is
>>> just about it.
>>> 
>>> Is there any inherent danger in having two
>>> ZooKeeperServer.takeSnapshot()
>>> overlapping their execution in time? Is it a thread to data integrity
>>> or is
>>> it just a possible performance issue?
>>> 
>>> I'm thinking of adding a new four-letter command to force a snapshot
>>> creation by a command from outside before snapCount threshold is
>>> reached.
>>> Is it safe to invoke ZooKeeperServer.takeSnapshot() from a four-word
>>> command handler or does it need to be submitted as a Request object into
>>> the pipeline of Request Processors?
>>> 
>>> 
>>> Regards,
>>> /Sergey
>>> 
> 


Re: Taking two snapshots at the same time

Posted by Thawan Kooburat <th...@fb.com>.
I have this functionality in our internal branch.

I can post the patch but it is likely to conflict with ZOOKEEPER-1346, so
it will be good to know the timeline of that patch.


-- 
Thawan Kooburat





On 7/8/13 11:48 AM, "Sergey Maslyakov" <ev...@gmail.com> wrote:

>I think I'd answer my own question. Apparently, if lastZxid does not
>change
>between two takeSnapshot() calls, they both will try to write into the
>same
>file. This is likely to explode when you try to read this snapshot back...
>So, the protection is needed.
>
>
>/Sergey
>
>
>On Mon, Jul 8, 2013 at 12:03 PM, Sergey Maslyakov <ev...@gmail.com>
>wrote:
>
>> From looking at the 3.4.5 code, it seems like
>> ZooKeeperServer.takeSnapshot() method does not have protection against
>> being invoked twice by different threads. There is some protection
>>against
>> spawning two snapshot threads from SyncRequestProcessor.run() but this
>>is
>> just about it.
>>
>> Is there any inherent danger in having two
>>ZooKeeperServer.takeSnapshot()
>> overlapping their execution in time? Is it a thread to data integrity
>>or is
>> it just a possible performance issue?
>>
>> I'm thinking of adding a new four-letter command to force a snapshot
>> creation by a command from outside before snapCount threshold is
>>reached.
>> Is it safe to invoke ZooKeeperServer.takeSnapshot() from a four-word
>> command handler or does it need to be submitted as a Request object into
>> the pipeline of Request Processors?
>>
>>
>> Regards,
>> /Sergey
>>


Re: Taking two snapshots at the same time

Posted by Sergey Maslyakov <ev...@gmail.com>.
I think I'd answer my own question. Apparently, if lastZxid does not change
between two takeSnapshot() calls, they both will try to write into the same
file. This is likely to explode when you try to read this snapshot back...
So, the protection is needed.


/Sergey


On Mon, Jul 8, 2013 at 12:03 PM, Sergey Maslyakov <ev...@gmail.com> wrote:

> From looking at the 3.4.5 code, it seems like
> ZooKeeperServer.takeSnapshot() method does not have protection against
> being invoked twice by different threads. There is some protection against
> spawning two snapshot threads from SyncRequestProcessor.run() but this is
> just about it.
>
> Is there any inherent danger in having two ZooKeeperServer.takeSnapshot()
> overlapping their execution in time? Is it a thread to data integrity or is
> it just a possible performance issue?
>
> I'm thinking of adding a new four-letter command to force a snapshot
> creation by a command from outside before snapCount threshold is reached.
> Is it safe to invoke ZooKeeperServer.takeSnapshot() from a four-word
> command handler or does it need to be submitted as a Request object into
> the pipeline of Request Processors?
>
>
> Regards,
> /Sergey
>