Hi all, Is the embedded mode thread-safe? I mean, once I have the Context object and opened a database, is it safe to access (read/write) it from multiple threads? Will the same transaction mechanism apply as if the server mode would be used? Thanks.
Hi Christian, I have setup a stress test to access the same DB in parallel. I have only one call to the Context constructor and using that same Context instance for all executions. I still get this exception: Caused by: java.nio.channels.OverlappingFileLockException at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255) at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152) at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1108) at org.basex.io.random.TableDiskAccess.lock(TableDiskAccess.java:139) at org.basex.data.DiskData.startUpdate(DiskData.java:207) at org.basex.query.up.ContextModifier.apply(ContextModifier.java:131) at org.basex.query.up.Updates.apply(Updates.java:157) at org.basex.query.QueryContext.iter(QueryContext.java:351) at org.basex.query.QueryProcessor.value(QueryProcessor.java:101)
I am accessing the returned elements (of the queries) via a Value.iter() iterator. The queries returns a sequence of 100 elements.
Each access to the DB has its own subtree. I.e. if "user 1" accesses the DB, then he only accesses the subtree assigned to him.
This is the DB tree structure: MyDB + users/usr1.xml/container + users/usr2.xml/container + ... + users/usrN.xml/container
Are iterators also thread-safe? If not, what can I use instead?
(Standalone unit test will follow.)
2016-10-06 20:07 GMT+02:00 Christian Grün christian.gruen@gmail.com:
I mean, once I have the Context object and opened a database, is it safe
to
access (read/write) it from multiple threads?
It depends on how you do it ;) If you call Command.execute() with the same Context instance, you should be safe.
You may need to call XQuery.execute, or call QueryProcessor.register (and, finally, unregister) before retrieving results; but maybe you should prepare an MCVE for us?
On Sun, Oct 9, 2016 at 4:20 PM, Erdal Karaca erdal.karaca.de@gmail.com wrote:
Hi Christian, I have setup a stress test to access the same DB in parallel. I have only one call to the Context constructor and using that same Context instance for all executions. I still get this exception: Caused by: java.nio.channels.OverlappingFileLockException at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255) at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152) at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1108) at org.basex.io.random.TableDiskAccess.lock(TableDiskAccess.java:139) at org.basex.data.DiskData.startUpdate(DiskData.java:207) at org.basex.query.up.ContextModifier.apply(ContextModifier.java:131) at org.basex.query.up.Updates.apply(Updates.java:157) at org.basex.query.QueryContext.iter(QueryContext.java:351) at org.basex.query.QueryProcessor.value(QueryProcessor.java:101)
I am accessing the returned elements (of the queries) via a Value.iter() iterator. The queries returns a sequence of 100 elements.
Each access to the DB has its own subtree. I.e. if "user 1" accesses the DB, then he only accesses the subtree assigned to him.
This is the DB tree structure: MyDB
- users/usr1.xml/container
- users/usr2.xml/container
- ...
- users/usrN.xml/container
Are iterators also thread-safe? If not, what can I use instead?
(Standalone unit test will follow.)
2016-10-06 20:07 GMT+02:00 Christian Grün christian.gruen@gmail.com:
I mean, once I have the Context object and opened a database, is it safe to access (read/write) it from multiple threads?
It depends on how you do it ;) If you call Command.execute() with the same Context instance, you should be safe.
Hi Christian, I have prepared a MCVE (see attachment). Not sure how to use QueryProcess.register/unregister. Is there an example? XQuery.execute() does not return objects, just a string?
2016-10-09 16:36 GMT+02:00 Christian Grün christian.gruen@gmail.com:
You may need to call XQuery.execute, or call QueryProcessor.register (and, finally, unregister) before retrieving results; but maybe you should prepare an MCVE for us?
On Sun, Oct 9, 2016 at 4:20 PM, Erdal Karaca erdal.karaca.de@gmail.com wrote:
Hi Christian, I have setup a stress test to access the same DB in parallel. I have only one call to the Context constructor and using that same Context instance
for
all executions. I still get this exception: Caused by: java.nio.channels.OverlappingFileLockException at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255) at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152) at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1108) at org.basex.io.random.TableDiskAccess.lock(TableDiskAccess.java:139) at org.basex.data.DiskData.startUpdate(DiskData.java:207) at org.basex.query.up.ContextModifier.apply(ContextModifier.java:131) at org.basex.query.up.Updates.apply(Updates.java:157) at org.basex.query.QueryContext.iter(QueryContext.java:351) at org.basex.query.QueryProcessor.value(QueryProcessor.java:101)
I am accessing the returned elements (of the queries) via a Value.iter() iterator. The queries returns a sequence of 100 elements.
Each access to the DB has its own subtree. I.e. if "user 1" accesses the DB, then he only accesses the subtree
assigned
to him.
This is the DB tree structure: MyDB
- users/usr1.xml/container
- users/usr2.xml/container
- ...
- users/usrN.xml/container
Are iterators also thread-safe? If not, what can I use instead?
(Standalone unit test will follow.)
2016-10-06 20:07 GMT+02:00 Christian Grün christian.gruen@gmail.com:
I mean, once I have the Context object and opened a database, is it
safe
to access (read/write) it from multiple threads?
It depends on how you do it ;) If you call Command.execute() with the same Context instance, you should be safe.
Would you mind rewriting it for Java 1.7?
Thanks in advance, Christian
On Sun, Oct 9, 2016 at 4:44 PM, Erdal Karaca erdal.karaca.de@gmail.com wrote:
Hi Christian, I have prepared a MCVE (see attachment). Not sure how to use QueryProcess.register/unregister. Is there an example? XQuery.execute() does not return objects, just a string?
2016-10-09 16:36 GMT+02:00 Christian Grün christian.gruen@gmail.com:
You may need to call XQuery.execute, or call QueryProcessor.register (and, finally, unregister) before retrieving results; but maybe you should prepare an MCVE for us?
On Sun, Oct 9, 2016 at 4:20 PM, Erdal Karaca erdal.karaca.de@gmail.com wrote:
Hi Christian, I have setup a stress test to access the same DB in parallel. I have only one call to the Context constructor and using that same Context instance for all executions. I still get this exception: Caused by: java.nio.channels.OverlappingFileLockException at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255) at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152) at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1108) at org.basex.io.random.TableDiskAccess.lock(TableDiskAccess.java:139) at org.basex.data.DiskData.startUpdate(DiskData.java:207) at org.basex.query.up.ContextModifier.apply(ContextModifier.java:131) at org.basex.query.up.Updates.apply(Updates.java:157) at org.basex.query.QueryContext.iter(QueryContext.java:351) at org.basex.query.QueryProcessor.value(QueryProcessor.java:101)
I am accessing the returned elements (of the queries) via a Value.iter() iterator. The queries returns a sequence of 100 elements.
Each access to the DB has its own subtree. I.e. if "user 1" accesses the DB, then he only accesses the subtree assigned to him.
This is the DB tree structure: MyDB
- users/usr1.xml/container
- users/usr2.xml/container
- ...
- users/usrN.xml/container
Are iterators also thread-safe? If not, what can I use instead?
(Standalone unit test will follow.)
2016-10-06 20:07 GMT+02:00 Christian Grün christian.gruen@gmail.com:
I mean, once I have the Context object and opened a database, is it safe to access (read/write) it from multiple threads?
It depends on how you do it ;) If you call Command.execute() with the same Context instance, you should be safe.
I have re-written the test to use 1.7, and also adapted register/unregister, but still I get this exception:
Caused by: org.basex.core.BaseXException: Database 'stress-test' is being updated, or update was not completed. at org.basex.data.DiskData.startUpdate(DiskData.java:210) at org.basex.query.up.ContextModifier.apply(ContextModifier.java:131)
2016-10-09 17:24 GMT+02:00 Christian Grün christian.gruen@gmail.com:
Would you mind rewriting it for Java 1.7?
Thanks in advance, Christian
On Sun, Oct 9, 2016 at 4:44 PM, Erdal Karaca erdal.karaca.de@gmail.com wrote:
Hi Christian, I have prepared a MCVE (see attachment). Not sure how to use QueryProcess.register/unregister. Is there an example? XQuery.execute() does not return objects, just a string?
2016-10-09 16:36 GMT+02:00 Christian Grün christian.gruen@gmail.com:
You may need to call XQuery.execute, or call QueryProcessor.register (and, finally, unregister) before retrieving results; but maybe you should prepare an MCVE for us?
On Sun, Oct 9, 2016 at 4:20 PM, Erdal Karaca <erdal.karaca.de@gmail.com
wrote:
Hi Christian, I have setup a stress test to access the same DB in parallel. I have only one call to the Context constructor and using that same Context
instance
for all executions. I still get this exception: Caused by: java.nio.channels.OverlappingFileLockException at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255) at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152) at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1108) at org.basex.io.random.TableDiskAccess.lock(TableDiskAccess.java:139) at org.basex.data.DiskData.startUpdate(DiskData.java:207) at org.basex.query.up.ContextModifier.apply(ContextModifier.java:131) at org.basex.query.up.Updates.apply(Updates.java:157) at org.basex.query.QueryContext.iter(QueryContext.java:351) at org.basex.query.QueryProcessor.value(QueryProcessor.java:101)
I am accessing the returned elements (of the queries) via a
Value.iter()
iterator. The queries returns a sequence of 100 elements.
Each access to the DB has its own subtree. I.e. if "user 1" accesses the DB, then he only accesses the subtree assigned to him.
This is the DB tree structure: MyDB
- users/usr1.xml/container
- users/usr2.xml/container
- ...
- users/usrN.xml/container
Are iterators also thread-safe? If not, what can I use instead?
(Standalone unit test will follow.)
2016-10-06 20:07 GMT+02:00 Christian Grün <christian.gruen@gmail.com
:
I mean, once I have the Context object and opened a database, is it safe to access (read/write) it from multiple threads?
It depends on how you do it ;) If you call Command.execute() with the same Context instance, you should be safe.
Thanks. It works if you call register/unregister for all QueryProcessor instances (including the nested one).
On Sun, Oct 9, 2016 at 7:11 PM, Erdal Karaca erdal.karaca.de@gmail.com wrote:
I have re-written the test to use 1.7, and also adapted register/unregister, but still I get this exception:
Caused by: org.basex.core.BaseXException: Database 'stress-test' is being updated, or update was not completed. at org.basex.data.DiskData.startUpdate(DiskData.java:210) at org.basex.query.up.ContextModifier.apply(ContextModifier.java:131)
2016-10-09 17:24 GMT+02:00 Christian Grün christian.gruen@gmail.com:
Would you mind rewriting it for Java 1.7?
Thanks in advance, Christian
On Sun, Oct 9, 2016 at 4:44 PM, Erdal Karaca erdal.karaca.de@gmail.com wrote:
Hi Christian, I have prepared a MCVE (see attachment). Not sure how to use QueryProcess.register/unregister. Is there an example? XQuery.execute() does not return objects, just a string?
2016-10-09 16:36 GMT+02:00 Christian Grün christian.gruen@gmail.com:
You may need to call XQuery.execute, or call QueryProcessor.register (and, finally, unregister) before retrieving results; but maybe you should prepare an MCVE for us?
On Sun, Oct 9, 2016 at 4:20 PM, Erdal Karaca erdal.karaca.de@gmail.com wrote:
Hi Christian, I have setup a stress test to access the same DB in parallel. I have only one call to the Context constructor and using that same Context instance for all executions. I still get this exception: Caused by: java.nio.channels.OverlappingFileLockException at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255) at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152) at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1108) at org.basex.io.random.TableDiskAccess.lock(TableDiskAccess.java:139) at org.basex.data.DiskData.startUpdate(DiskData.java:207) at org.basex.query.up.ContextModifier.apply(ContextModifier.java:131) at org.basex.query.up.Updates.apply(Updates.java:157) at org.basex.query.QueryContext.iter(QueryContext.java:351) at org.basex.query.QueryProcessor.value(QueryProcessor.java:101)
I am accessing the returned elements (of the queries) via a Value.iter() iterator. The queries returns a sequence of 100 elements.
Each access to the DB has its own subtree. I.e. if "user 1" accesses the DB, then he only accesses the subtree assigned to him.
This is the DB tree structure: MyDB
- users/usr1.xml/container
- users/usr2.xml/container
- ...
- users/usrN.xml/container
Are iterators also thread-safe? If not, what can I use instead?
(Standalone unit test will follow.)
2016-10-06 20:07 GMT+02:00 Christian Grün christian.gruen@gmail.com:
> I mean, once I have the Context object and opened a database, is > it > safe > to > access (read/write) it from multiple threads?
It depends on how you do it ;) If you call Command.execute() with the same Context instance, you should be safe.
basex-talk@mailman.uni-konstanz.de