Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[persistence] Persistence engine with couchdb has problems when documents are processed outside the engine #7

Closed
jfhbrook opened this issue May 10, 2013 · 4 comments

Comments

@jfhbrook
Copy link
Contributor

Basically, if you modify any documents using futon, you're going to have a bad time.

Here's tests:

5e7e4f9

tl;dr: updateOrCreate a creature, modify the creature using mikeal/request, get the creature, modify it with the persistence engine, and update it.

Here's the output from that test (tl;dr: modifications to life do not register after get, and returned object after get does not conform to update's schema):

# modify persisted documents outside of jugglingdb
ok 68 successfully created korben
ok 69 korben has life 10
ok 70 successfully requested couchdb document
ok 71 successfully modified couchd document
ok 72 successfully got korben
not ok 73 korben has life 100
  ---
    file:   /home/josh/dev/bigcompany/resource/index.js
    line:   733
    column: 9
    stack:  
      - getCaller (/home/josh/dev/bigcompany/resource/node_modules/tap/lib/tap-assert.js:418:17)
      - assert (/home/josh/dev/bigcompany/resource/node_modules/tap/lib/tap-assert.js:21:16)
      - Function.equal (/home/josh/dev/bigcompany/resource/node_modules/tap/lib/tap-assert.js:162:10)
      - Test._testAssert [as equal] (/home/josh/dev/bigcompany/resource/node_modules/tap/lib/tap-test.js:86:16)
      - /home/josh/dev/bigcompany/resource/test/persistence.js:291:13
      - /home/josh/dev/bigcompany/resource/index.js:685:29
      - afterHooks (/home/josh/dev/bigcompany/resource/index.js:733:9)
      - callbackWrap (/home/josh/dev/bigcompany/resource/index.js:681:18)
      - _args (/home/josh/dev/bigcompany/resource/index.js:651:33)
      - exports.enable.r.method.description (/home/josh/dev/bigcompany/resource/lib/persistence.js:140:7)
    found:  10
    wanted: 100
  ...
not ok 74 successfully updated korben
  ---
    type:    Error
    message: |
      Invalid arguments for method `creature.update`. [
        {
          "attribute": "type",
          "property": "metadata",
          "expected": "object",
          "actual": "object",
          "message": "must be of object type"
        },
        {
          "attribute": "type",
          "property": "items",
          "expected": "array",
          "actual": "object",
          "message": "must be of array type"
        }
      ]
    code:    ~
    errno:   ~
    file:    /home/josh/dev/bigcompany/resource/index.js
    line:    535
    column:  29
    stack:   
      - {
      - "attribute": "type",
      - "property": "metadata",
      - "expected": "object",
      - "actual": "object",
      - "message": "must be of object type"
      - },
      - {
      - "attribute": "type",
      - "property": "items",
      - "expected": "array",
      - "actual": "object",
      - "message": "must be of array type"
      - }
      - ]
      - execute (/home/josh/dev/bigcompany/resource/index.js:535:29)
      - /home/josh/dev/bigcompany/resource/index.js:409:16
      - beforeHooks (/home/josh/dev/bigcompany/resource/index.js:471:16)
      - /home/josh/dev/bigcompany/resource/index.js:400:14
      - beforeAllHooks (/home/josh/dev/bigcompany/resource/index.js:440:16)
      - EventEmitter.fn [as update] (/home/josh/dev/bigcompany/resource/index.js:391:12)
      - /home/josh/dev/bigcompany/resource/test/persistence.js:295:20
      - /home/josh/dev/bigcompany/resource/index.js:685:29
      - afterHooks (/home/josh/dev/bigcompany/resource/index.js:733:9)
      - callbackWrap (/home/josh/dev/bigcompany/resource/index.js:681:18)
  ...
not ok 75 korben has life 50
  ---
    file:   /home/josh/dev/bigcompany/resource/index.js
    line:   547
    column: 20
    stack:  
      - getCaller (/home/josh/dev/bigcompany/resource/node_modules/tap/lib/tap-assert.js:418:17)
      - assert (/home/josh/dev/bigcompany/resource/node_modules/tap/lib/tap-assert.js:21:16)
      - Function.equal (/home/josh/dev/bigcompany/resource/node_modules/tap/lib/tap-assert.js:162:10)
      - Test._testAssert [as equal] (/home/josh/dev/bigcompany/resource/node_modules/tap/lib/tap-test.js:86:16)
      - /home/josh/dev/bigcompany/resource/test/persistence.js:299:15
      - execute (/home/josh/dev/bigcompany/resource/index.js:547:20)
      - /home/josh/dev/bigcompany/resource/index.js:409:16
      - beforeHooks (/home/josh/dev/bigcompany/resource/index.js:471:16)
      - /home/josh/dev/bigcompany/resource/index.js:400:14
      - beforeAllHooks (/home/josh/dev/bigcompany/resource/index.js:440:16)
    found:  ~
    wanted: 50
    type:   
      found:  undefined
      wanted: undefined
  ...

I suspect that once the schema issues are resolved, that couchdb will fail to update due to an update conflict because jugglingdb appears to be caching.

@Marak
Copy link
Member

Marak commented May 10, 2013

There is a caching option within cradle. Wouldn't disabling this cache solve this problem?

@Marak
Copy link
Member

Marak commented May 10, 2013

The more I think about, I don't think caching is exposed to the resource API. We should add that as a configuration option to persist.

@jfhbrook
Copy link
Contributor Author

I think this would solve a lot. I'll look into exposing this.

@jfhbrook
Copy link
Contributor Author

These tests pass now, so I'm going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants