[MDSAL-775] Do not allow cross-datastore transactions Created: 10/Oct/22 Updated: 08/Nov/22 Resolved: 07/Nov/22 |
|
| Status: | Resolved |
| Project: | mdsal |
| Component/s: | DOM runtime |
| Affects Version/s: | None |
| Fix Version/s: | 11.0.0 |
| Type: | Task | Priority: | Medium |
| Reporter: | Robert Varga | Assignee: | Ruslan Kashapov |
| Resolution: | Done | Votes: | 0 |
| Labels: | pt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
The ability to access multiple datastores in a single transaction is something we supported on a best-effort basis, but there is no concept of cross-datastore atomicity. As such, no downstreams should be using this facility – remove this ability, forcing users to have a separate transaction for each datastore. |
| Comments |
| Comment by Ruslan Kashapov [ 13/Oct/22 ] |
|
there is a limitation to what can be done as solution for current task in order to operate with data from a specific datastore the composite transaction
final WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.merge(LogicalDatastoreType.CONFIGURATION, DATA_IID, data);
it means backing transactions for all the datastores require to be instantiated the composite transaction is being created by dataBroker from the set of datastores necessity to have separate databroker instance for each datastore isn't suitable #1 the compromise solution could be logical restriction within transaction itself by controlling final WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); tx.merge(LogicalDatastoreType.CONFIGURATION, DATA_IID, data); // first operation, datastore type registered tx.merge(LogicalDatastoreType.CONFIGURATION, DATA_IID2, data2); // datastore matches, passed ok tx.merge(LogicalDatastoreType.OPERATIONAL, DATA_IID, data); // datastore mismatches, exception thrown while this approach solves 'single datastore per transaction' while API remain as is, #2 imo more reasonable approach would be introducing new api using single store transactions, // new transaction interfaces, new databroker methods to build single datastore transactions final DatastoreWriteTransaction tx = dataBroker.newWriteOnlyTransaction(LogicalDatastoreType.CONFIGURATION); tx.merge(DATA_IID, data); // datastore is known already while this approach seems more future-proof, it also requires more effort and a new set of #3 // old transaction interfaces, new databroker methods final WriteTransaction tx = dataBroker.newWriteOnlyTransaction(LogicalDatastoreType.CONFIGURATION); tx.merge(LogicalDatastoreType.CONFIGURATION, DATA_IID, data); // ok tx.merge(LogicalDatastoreType.OPERATIONAL, DATA_IID, data); // IllegalStateException, current behavior the approach need to be clarified
|
| Comment by Robert Varga [ 13/Oct/22 ] |
|
Approach 1, definitely, as we need to catch violations first and allow implementations to rely on the fact this is not allowed. We have datastore-bound versions of the WriteTransaction et al. prepared, but rolling those out is going to be a point. |