elbart / node-memcache

node.js memcached client
285 stars 64 forks source link

Exceptions while big load #26

Open shunanya opened 12 years ago

shunanya commented 12 years ago

When I use memcache library on big load (more than 20 req/sec) I am get the exception during getting data like depicted below


/home/shunanya/worksp_node/test/node_modules/memcache/lib/memcache.js:260
    var type = this.callbacks[0].type;
                                ^
TypeError: Cannot read property 'type' of undefined
    at Client.determine_reply_handler (/home/shunanya/worksp_node/test/node_modules/memcache/lib/memcache.js:260:30)
    at Client.handle_received_data (/home/shunanya/worksp_node/test/node_modules/memcache/lib/memcache.js:217:21)
    at Socket.Client.connect.conn.addListener.self.conn (/home/shunanya/worksp_node/test/node_modules/memcache/lib/memcache.js:62:12)
    at Socket.EventEmitter.emit (events.js:88:17)
    at TCP.onread (net.js:403:14)

In my opinion, it doesn't have enough time to store the callback function in the array and this is the reason for exception. I use currently the Node.js 0.8.8 and Memcached 1.4.14 under Ubuntu 11.10. Hope, this issue can be fixed soon:)

Simon

hbhasker commented 12 years ago

This is an issue I am noticing as well. From what I can see it fires the callback before the data is complete or something sometimes or is firing a callback when none exist.

giggsey commented 11 years ago

+1

1999 commented 11 years ago

It seems like the error does not depend on the number of the tasks being made to memcached server. Some piece of data comes when no listener is bound. The data comes without any request being made to memcached server, so the problem is to get what is this piece of data about.

// dirty hack (stderr will also contain the data):
this.conn.addListener("data", function (data) {
  self.buffer += data;
  try {
    self.handle_received_data();
  } catch (e) {
    util.error('Error: data handling impossible. Data chunk: ' + data);
    self.buffer = '';
  }
});

UPD: i created a gist repository to reproduce this problem: https://gist.github.com/4554582 Pull request from issue #22 fixes this just partly

henpatel commented 11 years ago

Hey guys, we are having a similar issue. Is there a work around?

1999 commented 11 years ago

@henpatel i moved to npm's memcached, but found another bug. Whoa! If you want to continue using node-memcache, look #22 for partial fix of this problem.

masonzhang commented 11 years ago

This happens on my server also, I use latest node-memcache and Couchbase to setup memcached server. Any thoughts? Here are my full call stack:

/Server/node_modules/memcache/lib/memcache.js:260 var type = this.callbacks[0].type; ^ TypeError: Cannot read property 'type' of undefined at Client.determine_reply_handler (/Server/node_modules/memcache/lib/memcache.js:260:30) at Client.handle_received_data (/Server/node_modules/memcache/lib/memcache.js:217:21) at Socket. (/Server/node_modules/memcache/lib/memcache.js:62:12) at Socket.EventEmitter.emit (events.js:95:17) at Socket. (_streamreadable.js:736:14) at Socket.EventEmitter.emit (events.js:92:17) at emitReadable (_stream_readable.js:408:10) at emitReadable (_stream_readable.js:404:5) at readableAddChunk (_stream_readable.js:165:9) at Socket.Readable.push (_stream_readable.js:127:10)

exos commented 11 years ago

I Have the same error, and I tryed with compress the data and fails.

masonzhang commented 11 years ago

@exos The answer is in comment of the user "1999". Pull Request #23: Fixed bug when 'END' is contained in the cached data. But it does not completely fix this issue.