transactionscope - RavenDb - How can I save changes to multiple document sessions in one transaction? -
within single transaction scope, trying save data 2 separate raven databases (on same raven server).
however, changes in second session not being saved server.
here code using:
var documentstore = new documentstore { url = "http://localhost:8081/" }; documentstore.initialize(); documentstore.databasecommands.ensuredatabaseexists("database1"); documentstore.databasecommands.ensuredatabaseexists("database2"); using (var ts = new transactionscope(transactionscopeoption.requiresnew)) { using (var session1 = documentstore.opensession("database1")) { session1.store(new entity {id = "1"}); session1.savechanges(); } using (var session2 = documentstore.opensession("database2")) { session2.store(new entity {id = "2"}); session2.savechanges(); } ts.complete(); }
i can see changes in session1
being saved database1
changes in session2
not saved database2
. i've tried ravendb build 992 , build 2360
according raven documentation, transactions across databases supported.
how can changes session2
committed?
the distributed transaction needs time commit. can either wait briefly thread.sleep
before checking result, or can set special property in session checking result:
session.advanced.allownonauthoritativeinformation = false;
this seems bug, design. read working system.transactions in ravendb documentation.
(fyi - didn't know either until checked.)
Comments
Post a Comment