#1 2016-06-14 05:14:14

oraclei
Member
Registered: 2016-06-06
Posts: 18

Can concurrent writing with ORM?

I read the document, In 8.3.7, it said:By default, all ORM read operations will be run in concurrent mode, and all ORM write operations will be executed in blocking mode. This is expected to be both safe and fast, with our internal  SQLite3 engine, or most of the external databases.

...  To avoid such problems, you can force all ORM write operations to be executed in a dedicated thread, i.e. by setting amMainThread (which is not very
opportune on a server without UI), or even better via  amBackgroundThread  or a amBackgroundORMSharedThread

Does it mean must use dedicated thread for writing?  I don't like this policy, it seems like mysql SERIALIZABLE transaction isolation levels, and can make writing bottleneck, while mysql or mssql support concurrent writing.

mORMot has connection pool, per-thread in connection pool has it own transaction, why threads can not read/write concurrently ?  the ZeroC ICE can do like these.

Offline

#2 2016-06-14 17:29:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,718
Website

Re: Can concurrent writing with ORM?

Because the incoming REST requests may come in diverse threads, so you can't ensure that the same client would send subsequent ORM requests with the same thread, so your per-thread transaction is voided.
Unless you use Batch process, which is the intended way of using transactions.

Offline

#3 2016-06-14 21:43:15

oraclei
Member
Registered: 2016-06-06
Posts: 18

Re: Can concurrent writing with ORM?

If REST client calls sql or something like using transaction, it would be wrong as you point: (for server side) the incoming REST requests may come in diverse threads.  As far as I know , if transaction always in REST server not client, per-thread transaction is practicable, whenever client call function on server, must be completed by one time. REST Server function is atomic. So, it disallows using sql on client, client only calls functions on server, server does sql operation in transaction. every client call leads to server's per-thread do a transaction operation.

When my program obey this policy, can I set the mORMot concurrent writing?

Offline

#4 2016-06-15 02:12:02

oraclei
Member
Registered: 2016-06-06
Posts: 18

Re: Can concurrent writing with ORM?

I find out TSQLRestClientDB has TransactionBegin, this means transaction call on client side, this is why server side not support concurrent writing. I think that client can use sql direct through server to operating database is not a good idea.

Offline

Board footer

Powered by FluxBB