db.remove drastically broken #97

Closed
timoxley opened this Issue Oct 17, 2011 · 10 comments

Projects

None yet

6 participants

@timoxley

Perhaps this is a Riak 1.0 issue, but any call to remove will break any following call to getAll with a 500, and attempts to get keys will report that the item is still in the bucket D:

Gist Here: https://gist.github.com/1292272

Test:

var db = require('riak-js').getClient({port: 8098, debug: true})


exports['can call remove then call getAll'] = function(test) {
  var bucket = 'Bugs'
  var key = 'KLM'
  var object = {
    "frustrating": true
  }

 db.save(bucket, key, {fleet: 111, country: 'NL'}, function(err, data, meta) {
    test.ok(!err, 'save: ' + err)
    db.remove(bucket, key, function(err){
      test.ok(!err, 'remove: '+ err)
      db.getAll(bucket, function(err, data){
        test.ok(!err, 'getAll: ' + err)
        test.equal(data.length, 0, 'data.length should be 0!')
        test.done()
      })
    })

  })
}
exports['can call remove and item will actually be removed'] = function(test) {
  var bucket = 'airlines'
  var key = 'KLM'
  var object = {
    frustrating: true
  }
  db.save(bucket, key, {fleet: 111, country: 'NL'}, function(err, data, meta) {
    test.ok(!err, 'save: ' + err)
    db.remove(bucket, key, function(err){
      test.ok(!err, 'remove: '+ err)
      db.keys(bucket, function(err, keys){
        test.ok(!err, 'keys: ' + err)
        test.equal(keys.length, 0, 'keys.length should be 0!')
        test.done()
      })
    })
  })
}

Output:

chamb% nodeunit test/units/test_bug.js

test_bug.js
[riak-js] PUT /riak/Bugs/KLM
[riak-js] DELETE /riak/Bugs/KLM
[riak-js] POST /mapred
✖ can call remove then call getAll

Assertion Message: getAll: Error: HTTP error 500: {"lineno":466,"message":"SyntaxError: syntax error","source":"()"}
AssertionError: false == true
    at Object.ok (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)
    at .../test/units/test_bug.js:16:14
    at HttpClient.<anonymous> (.../node_modules/riak-js/lib/http_client.js:378:18)
    at IncomingMessage.<anonymous> (.../node_modules/riak-js/lib/http_client.js:10:95)
    at IncomingMessage.emit (events.js:81:20)
    at HTTPParser.onMessageComplete (http.js:133:23)
    at Socket.ondata (http.js:1231:22)
    at Socket._onReadable (net.js:677:27)
    at IOWatcher.onReadable [as callback] (net.js:177:10)

Assertion Message: data.length should be 0!
AssertionError: undefined == 0
    at Object.equal (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)
    at .../test/units/test_bug.js:17:14
    at HttpClient.<anonymous> (.../node_modules/riak-js/lib/http_client.js:378:18)
    at IncomingMessage.<anonymous> (.../node_modules/riak-js/lib/http_client.js:10:95)
    at IncomingMessage.emit (events.js:81:20)
    at HTTPParser.onMessageComplete (http.js:133:23)
    at Socket.ondata (http.js:1231:22)
    at Socket._onReadable (net.js:677:27)
    at IOWatcher.onReadable [as callback] (net.js:177:10)

[riak-js] PUT /riak/airlines/KLM
[riak-js] DELETE /riak/airlines/KLM
[riak-js] GET /riak/airlines?keys=true
✖ can call remove and item will actually be removed

Assertion Message: keys.length should be 0!
AssertionError: 1 == 0
    at Object.equal (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)
    at .../test/units/test_bug.js:36:14
    at .../node_modules/riak-js/lib/http_client.js:98:18
    at HttpClient.<anonymous> (.../node_modules/riak-js/lib/http_client.js:378:18)
    at IncomingMessage.<anonymous> (.../node_modules/riak-js/lib/http_client.js:10:95)
    at IncomingMessage.emit (events.js:81:20)
    at HTTPParser.onMessageComplete (http.js:133:23)
    at Socket.ondata (http.js:1231:22)
    at Socket._onReadable (net.js:677:27)
    at IOWatcher.onReadable [as callback] (net.js:177:10)


FAILURES: 3/8 assertions failed (51ms)
@f3z0

On line 112 of http_client.js I switched the verbiage from DELETE to REMOVE and it seemed to fix the issue for me. I am a newb though so don't trust me :)

@f3z0

Don't listen to me, didn't realize that was the http verb until second glance.

@frank06

Looks like a bug in Riak. Two observations:

1) Executing a save, remove and getAll in the REPL yields the error, but if enough time is left between remove and getAll it works ok

2) It's nothing in the getAll function, db.add('bugs').map('Riak.mapValuesJson').run() has the same effect

Using Riak 1.0.1

@frank06 frank06 closed this Oct 30, 2011
@timoxley

Thanks for looking into this, but why was it closed?

@frank06

Because it's not a riak-js issue. I have reported it on the mailing list

@frank06
=>  curl -v -X DELETE http://127.0.0.1:7098/riak/bugs/KLM
* About to connect() to 127.0.0.1 port 7098 (#0)
*   Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 7098 (#0)
> DELETE /riak/bugs/KLM HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
> Host: 127.0.0.1:7098
> Accept: */*
> 
< HTTP/1.1 204 No Content
< Vary: Accept-Encoding
< Server: MochiWeb/1.1 WebMachine/1.9.0 (participate in the frantic)
< Date: Mon, 31 Oct 2011 10:24:45 GMT
< Content-Type: application/json
< Content-Length: 0
< 
* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0

 =>  curl -v -d '{"inputs":"bugs", "query":[{"map":{"language":"javascript","name":"Riak.mapValuesJson"}}] }' -H "Content-Type: application/json" http://127.0.0.1:7098/mapred
* About to connect() to 127.0.0.1 port 7098 (#0)
*   Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 7098 (#0)
> POST /mapred HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
> Host: 127.0.0.1:7098
> Accept: */*
> Content-Type: application/json
> Content-Length: 91
> 
< HTTP/1.1 500 Internal Server Error
< Server: MochiWeb/1.1 WebMachine/1.9.0 (participate in the frantic)
< Date: Mon, 31 Oct 2011 10:24:46 GMT
< Content-Type: application/json
< Content-Length: 66
< 
* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0
{"lineno":466,"message":"SyntaxError: syntax error","source":"()"}
@igagen

I'm not sure if the above merge was intended to address this issue, but I'm still experiencing it.

@frank06

Hi, I am no longer maintaining this project. Please find the new official repository at senchalabs/riak-js

@emilyrose

or the new-new official repository at mostlyserious/riak-js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment