[odb-users] Feature request: relationships not in pointers

Feiyun Wang feiyunw at yahoo.com
Tue Jul 24 05:20:48 EDT 2018


Hi,
In the ODB manual, Chapter 6 Relationships:> Relationships between persistent objects are expressed with pointers or containers of pointers.I suggest to add the support for relationships expressed in the ODB pragma language.
When considering using ODB for a MMORPG server, I found that it may cause some problem for relationships expressed with pointers.Because some database I/O may block for 100+ ms, database operations are not allowed in the main thread which handles a very high throughput (1K+ requests/second) and requires the best response time.In such scenario, we have to have a dedicated database thread to handle database I/O.If using ODB, we will create the persistent objects in this database thread and pass the objects to the main thread. The main thread will regularly pass the copies of the modified objects back to the database thread to update the database records. (We achieve this by sending SQL statements to the database thread now without ODB.)When the persistent objects have pointer members but we don't create copies of the pointed objects, it may cause access conflict (database thread reads, main thread writes). But adding copies for the pointed objects will be a tedious and error-prone task.The solution will be: Never use a pointer in an ODB persistent class. Where a pointer should be, use the primary key data type for the pointed class instead.However, this solution will exclude the ODB relationship functionality. That's why I asked for the relationships expressed with other means than pointers.
I understand the pointer member is very crucial to full C++ ORM capability, but that may not be what we want in the multithreaded environments.Any ideas?
Sincerely,Feiyun Wang


More information about the odb-users mailing list