appy-one / acebase

A fast, low memory, transactional, index & query enabled NoSQL database engine and server for node.js and browser with realtime data change notifications
MIT License
492 stars 27 forks source link

DEBUG THIS: getNodeInfo error #168

Closed donl closed 2 years ago

donl commented 2 years ago

I just ran into this error. I'll see if I can get you something reproducible. This is from an acebase-server that was having dummy data (2k small objects) added from a remote client.

[default] DEBUG THIS: getNodeInfo error DetailedError: Set tree.id property to something unique for locking purposes
    at BinaryBPlusTree._threadSafe (/app/node_modules/acebase/src/btree/binary-tree.js:853:19)
    at BinaryBPlusTree.findAll (/app/node_modules/acebase/src/btree/binary-tree.js:1539:21)
    at createStreamFromBinaryTree (/app/node_modules/acebase/src/storage/binary/index.js:2589:44)
    at start (/app/node_modules/acebase/src/storage/binary/index.js:2551:24)
    at async NodeReader.getChildInfo (/app/node_modules/acebase/src/storage/binary/index.js:2872:9)
    at async AceBaseStorage.getNodeInfo (/app/node_modules/acebase/src/storage/binary/index.js:1763:33)
    at async LocalApi.reflect (/app/node_modules/acebase/src/api-local.js:213:34)
    at async file:///app/node_modules/acebase-server/dist/esm/routes/data-reflect.js:47:28 {
  code: 'tree-id-not-set',
  originalError: null
}
appy-one commented 2 years ago

If I follow the stack trace it looks like you are adding those objects to the root node of the db, is that right?

This line sets the tree.id: https://github.com/appy-one/acebase/blob/74a2c54f8ace839dfda0cd19b05184ef3566bf91/src/storage/binary/index.js#L2568

If path === '', so will tree.id be and fail the assertion with given error.

Can you try changing the line above to tree.id = 'path:' + this.address.path; and let me know if that fixes it?

donl commented 2 years ago

Correct, these objects were being added to the root node.

I patched the code on the server. I replaced my server's /node_modules/acebase with your repo, made the change and built acebase. The error still occurred. Do I need to try and update my acebase-client app as well?

donl commented 2 years ago

Starting with a fresh db, this is what I'm seeing upon database creation...

[mydb] DEBUG THIS: getNodeInfo error DetailedError: Set tree.id property to something unique for locking purposes
    at BinaryBPlusTree._threadSafe (/ace-server-test/node_modules/acebase/src/btree/binary-tree.js:853:19)
    at BinaryBPlusTree.findAll (/ace-server-test/node_modules/acebase/src/btree/binary-tree.js:1539:21)
    at createStreamFromBinaryTree (/ace-server-test/node_modules/acebase/src/storage/binary/index.js:2589:44)
    at start (/ace-server-test/node_modules/acebase/src/storage/binary/index.js:2551:24)
    at async NodeReader.getChildInfo (/ace-server-test/node_modules/acebase/src/storage/binary/index.js:2872:9)
    at async AceBaseStorage.getNodeInfo (/ace-server-test/node_modules/acebase/src/storage/binary/index.js:1763:33)
    at async AceBaseStorage.getNodeInfo (/ace-server-test/node_modules/acebase/src/storage/binary/index.js:1739:36)
    at async AceBaseStorage.getNodeInfo (/ace-server-test/node_modules/acebase/src/storage/binary/index.js:1739:36)
    at async AceBaseStorage.getNode (/ace-server-test/node_modules/acebase/src/storage/binary/index.js:1629:30)
    at async AceBaseStorage.transactNode (/ace-server-test/node_modules/acebase/src/storage/index.js:1119:26) {
  code: 'tree-id-not-set',
  originalError: null
}
donl commented 2 years ago

I must be missing a step. It looks like after running npm run build in the acebase directory, my modification to acebase/src/storage/binary/index.js is being reverted.

donl commented 2 years ago

When I only edit the .js file (without additional building) I am seeing these types of messages when attempting to log in and being stuck waiting for the server to respond.

storage.getNode "/__auth__/accounts/admin") is taking a long time to complete

appy-one commented 2 years ago

I must be missing a step. It looks like after running npm run build in the acebase directory, my modification to acebase/src/storage/binary/index.js is being reverted.

Yes, that's why I asked to change the .js file, that would have been the only needed change. If you'd change the .ts file you would have needed to rebuild, I wanted to save you the hassle ;-)

I am seeing these types of messages when attempting to log in and being stuck waiting for the server to respond. storage.getNode "/auth/accounts/admin") is taking a long time to complete

Are you logging in while your bulk adds are being processed?

donl commented 2 years ago

The login was on a fresh server / database file. I wasn't able to proceed any further. I'll try another fresh server setup with no authentication.

The npm installed acebase package didn't have the .js files you referenced. Going off your git repo, I was more out of my element -- but a good lesson for me none the less. :)

appy-one commented 2 years ago

Did you update acebase-server after I fixed https://github.com/appy-one/acebase-server/issues/40 ? Because if you didn't, you are now using a newer acebase version than your old acebase-server package expects - that might cause issues.

appy-one commented 2 years ago

Hi Don, I published the fix in acebase v1.25.2 Let me know if you still see that last error you reported after updating acebase-server to the latest version