You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by kaka chen <ka...@gmail.com> on 2012/09/21 05:32:13 UTC

Confused about the process of handle BADVERSION at setData() method in RecoverableZookeeper.java

Hi All:
    Can someone explain the handle BADVERSION at setData() method in
RecoverableZookeeper.java, I am very confused. The meta data is MAGIC(1
BYTE) + LENGTH_FIELD(4 BYTE) + ID + DATA, but the parsing is very strange,
and why to compare id with data? Please help me, thanks!

            case BADVERSION:
            // try to verify whether the previous setData success or not
            try{
              Stat stat = new Stat();
              byte[] revData = zk.getData(path, false, stat);
              int idLength = Bytes.toInt(revData, ID_LENGTH_SIZE);
              int dataLength = revData.length-ID_LENGTH_SIZE-idLength;
              int dataOffset = ID_LENGTH_SIZE+idLength;

              if(Bytes.compareTo(revData, ID_LENGTH_SIZE, id.length,
                  revData, dataOffset, dataLength) == 0) {
                // the bad version is caused by previous successful setData
                return stat;
              }
            } catch(KeeperException keeperException){
              // the ZK is not reliable at this moment. just throwing
exception
              throw keeperException;
            }

Kaka Chen

Re: Confused about the process of handle BADVERSION at setData() method in RecoverableZookeeper.java

Posted by kaka chen <ka...@gmail.com>.
Thanks for your patch!

2012/9/22 Stack <st...@duboce.net>

> On Fri, Sep 21, 2012 at 2:02 PM, Stack <st...@duboce.net> wrote:
> > I asked the author Liyin and he looked at it.  Says its a bug too.  He
> > hopes to fix it (I made
> > https://issues.apache.org/jira/browse/HBASE-6859).  Do you have a fix?
> >
>
> Liyin put up a patch in
> https://issues.apache.org/jira/browse/HBASE-6858.  You want to check
> it out Kaka?
> Thanks,
> St.Ack
>

Re: Confused about the process of handle BADVERSION at setData() method in RecoverableZookeeper.java

Posted by Stack <st...@duboce.net>.
On Fri, Sep 21, 2012 at 2:02 PM, Stack <st...@duboce.net> wrote:
> I asked the author Liyin and he looked at it.  Says its a bug too.  He
> hopes to fix it (I made
> https://issues.apache.org/jira/browse/HBASE-6859).  Do you have a fix?
>

Liyin put up a patch in
https://issues.apache.org/jira/browse/HBASE-6858.  You want to check
it out Kaka?
Thanks,
St.Ack

Re: Confused about the process of handle BADVERSION at setData() method in RecoverableZookeeper.java

Posted by Stack <st...@duboce.net>.
On Thu, Sep 20, 2012 at 10:00 PM, Stack <st...@duboce.net> wrote:
> On Thu, Sep 20, 2012 at 8:32 PM, kaka chen <ka...@gmail.com> wrote:
>> Hi All:
>>     Can someone explain the handle BADVERSION at setData() method in
>> RecoverableZookeeper.java, I am very confused. The meta data is MAGIC(1
>> BYTE) + LENGTH_FIELD(4 BYTE) + ID + DATA, but the parsing is very strange,
>> and why to compare id with data? Please help me, thanks!
>>
>>             case BADVERSION:
>>             // try to verify whether the previous setData success or not
>>             try{
>>               Stat stat = new Stat();
>>               byte[] revData = zk.getData(path, false, stat);
>>               int idLength = Bytes.toInt(revData, ID_LENGTH_SIZE);
>>               int dataLength = revData.length-ID_LENGTH_SIZE-idLength;
>>               int dataOffset = ID_LENGTH_SIZE+idLength;
>>
>>               if(Bytes.compareTo(revData, ID_LENGTH_SIZE, id.length,
>>                   revData, dataOffset, dataLength) == 0) {
>
>
> I don't know.  The above looks wong to me.  Maybe if I read more of
> RecoverableZooKeeper, it'd make sense (but I doubt it).
>
> Se we tried to setData but the version proffered was wrong; someone
> else had changed it on us.
>
> Is there a broader context?
>

I asked the author Liyin and he looked at it.  Says its a bug too.  He
hopes to fix it (I made
https://issues.apache.org/jira/browse/HBASE-6859).  Do you have a fix?

Thanks,
St.Ack

Re: Confused about the process of handle BADVERSION at setData() method in RecoverableZookeeper.java

Posted by Stack <st...@duboce.net>.
On Thu, Sep 20, 2012 at 8:32 PM, kaka chen <ka...@gmail.com> wrote:
> Hi All:
>     Can someone explain the handle BADVERSION at setData() method in
> RecoverableZookeeper.java, I am very confused. The meta data is MAGIC(1
> BYTE) + LENGTH_FIELD(4 BYTE) + ID + DATA, but the parsing is very strange,
> and why to compare id with data? Please help me, thanks!
>
>             case BADVERSION:
>             // try to verify whether the previous setData success or not
>             try{
>               Stat stat = new Stat();
>               byte[] revData = zk.getData(path, false, stat);
>               int idLength = Bytes.toInt(revData, ID_LENGTH_SIZE);
>               int dataLength = revData.length-ID_LENGTH_SIZE-idLength;
>               int dataOffset = ID_LENGTH_SIZE+idLength;
>
>               if(Bytes.compareTo(revData, ID_LENGTH_SIZE, id.length,
>                   revData, dataOffset, dataLength) == 0) {


I don't know.  The above looks wong to me.  Maybe if I read more of
RecoverableZooKeeper, it'd make sense (but I doubt it).

Se we tried to setData but the version proffered was wrong; someone
else had changed it on us.

Is there a broader context?

St.Ack



>                 // the bad version is caused by previous successful setData
>                 return stat;
>               }
>             } catch(KeeperException keeperException){
>               // the ZK is not reliable at this moment. just throwing
> exception
>               throw keeperException;
>             }
>
> Kaka Chen