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

Can't use node-api by worker_threads #3

Open
cjy543731778 opened this issue Sep 30, 2021 · 5 comments
Open

Can't use node-api by worker_threads #3

cjy543731778 opened this issue Sep 30, 2021 · 5 comments

Comments

@cjy543731778
Copy link

I try to use two workers to query a container list, but it failed with the error message.
It seem that api can't work on the multithreading.

FATAL ERROR: HandleScope::HandleScope Entering the V8 API without proper locking in place
 1: 0xb14d40 node::Abort() [node]
 2: 0xa31e30 node::FatalError(char const*, char const*) [node]
 3: 0xcfb67a v8::Utils::ReportApiFailure(char const*, char const*) [node]
 4: 0xcfcedc v8::EscapableHandleScope::EscapableHandleScope(v8::Isolate*) [node]
 5: 0xacc766 napi_open_escapable_handle_scope [node]
 6: 0x7ff67ed6c06f griddb::StoreFactory::getInstance(Napi::CallbackInfo const&) [/home/a/nodejs-api/node-api/griddb.node]
 7: 0x7ff67ed749af Napi::ObjectWrap<griddb::StoreFactory>::StaticMethodCallbackWrapper(napi_env__*, napi_callback_info__*) [/home/a/nodejs-api/node-api/griddb.node]
 8: 0xac44af  [node]
 9: 0xd627db  [node]
10: 0xd63c7c  [node]
11: 0xd642f6 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x1611ad9  [node]
中止 (コアダンプ)
@knonomura
Copy link
Member

Thank you for your usage.

I have a question.
Do you assign a different Store object for each thread ?

I guess you use StoreFactory::getInstance() method on the multithreading.

@cjy543731778
Copy link
Author

Thank you for your usage.

I have a question. Do you assign a different Store object for each thread ?

I guess you use StoreFactory::getInstance() method on the multithreading.

Yes, Thanks to your reply. Your guess is totally right.
I cannot find help in document, so that i try this code in multithreading worker.

var factory = new griddb.StoreFactory();
var store = factory.getStore({
    "host": '127.0.0.1',
    "port": 10001,
    "clusterName": "defaultCluster",
    "username": "admin",
    "password": "admin"
});

But it seem unworkable in multithreading. The result is Segmentation fault (コアダンプ), or below error message.

events.js:377
      throw er; // Unhandled 'error' event
      ^
Error [ERR_UNHANDLED_ERROR]: Unhandled error. (GSException {
  mCode: -1,
  mMessage: 'Wrong arguments',
  mLocation: '',
  mStackSize: 1
})
    at new NodeError (internal/errors.js:322:7)
    at process.emit (events.js:389:17)
    at emitUnhandledRejectionOrErr (internal/event_target.js:579:11)
    at MessagePort.[nodejs.internal.kHybridDispatch] (internal/event_target.js:403:9)
    at MessagePort.exports.emitMessage (internal/per_context/messageport.js:18:26)
Emitted 'error' event on process instance at:
    at emitUnhandledRejectionOrErr (internal/event_target.js:579:11)
    at MessagePort.[nodejs.internal.kHybridDispatch] (internal/event_target.js:403:9)
    at MessagePort.exports.emitMessage (internal/per_context/messageport.js:18:26) {
  code: 'ERR_UNHANDLED_ERROR',
  context: {
    mCode: -1,
    mMessage: 'Wrong arguments',
    mLocation: '',
    mStackSize: 1
  }
}

@knonomura
Copy link
Member

I understand.
I'll check this issue.

@knonomura
Copy link
Member

I fixed this issue.
Could you please use the latest source code ?

@cjy543731778
Copy link
Author

I fixed this issue. Could you please use the latest source code ?

Thank you very much.I will try it.

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