zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mudit Verma <mudit.f2004...@gmail.com>
Subject very strange behavior - data is not written in ZK
Date Mon, 29 Sep 2014 15:13:28 GMT

I have following function which sets a value to a znode as 1 or 0. However,
the value is not getting set in Zookeeper ( data version is being changed
though). This piece of code used to work, until I upgraded the cluster to
latest zookeeper version.

Any idea what is going wrong? Your help is much appreciated !!


*zk_map_lock(zk_map *zkm) { *

   struct Stat *stats = (struct Stat *)xcalloc(1,sizeof(struct Stat));

   int lock, size;

   *int rc,zrc = zoo_get(zkm->zk, zkm->path, 0, (char *)&lock,
&size,stats);  * /*/getting the lock value from ZK*

   if(zrc ==ZOK) {

        //here we need to grab the lock

        if(lock == 0) {

           printf("\n zk_map_lock %s lock:%d version:%d"


           int zrc2 = *zoo_set(zkm->zk, zkm->path,(char *)&lock,
sizeof(int),stats->version);  //if zero setting to 1*

           if(zrc2 == ZOK){

                printf("\n Returning Success");fflush(stdout);

                rc = ZK_MAP_SUCCESS;

           } else

                rc = ZK_MAP_FAILURE;



           rc = ZK_MAP_FAILURE;


   else if(zrc == ZNONODE)

        rc = ZK_MAP_ENOENT;


        rc = ZK_MAP_FAILURE;

   //testing need to be removed later on


   *zrc = zoo_get(zkm->zk, zkm->path, 0, (char *)&lock, &size,stats);
 //retrieving the value  and it is still 0 -->very strange*

   printf("\n zrc:%d zk_map_lock %s lock:%d version:%d"


   return rc;




*Printf1:   zk_map_lock /dir/6549211657075368907 lock:0 version:0*

*Printf2:   zrc:0 zk_map_lock /dir/6549211657075368907 lock:0 version:1*

Thanks, Mudit

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message