[CONTROLLER-592] Always get ConflictingModificationException when writing Created: 02/Jul/14  Updated: 25/Jul/23  Due: 18/Jul/14  Resolved: 25/Jul/14

Status: Resolved
Project: controller
Component/s: mdsal
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Rob Adams Assignee: Tony Tkacik
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Linux
Platform: PC


External issue ID: 1280

 Description   

I'm trying to write to the operational store from an RPC method. The problem is that even though there's only one write happening anywhere and no deletes, nonetheless I always get back:

org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException: errors: [error-type: application, error-tag: operation-failed, error-message: The operation encountered an unexpected error while executing.error-info: org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException: Node was deleted by other transaction.

A slightly simplified version of the code is below. This was working with the old API.

Function<RpcResult<TransactionStatus>, RpcResult<Void>> futureTrans =
new Function<RpcResult<TransactionStatus>,RpcResult<Void>>() {
@Override
public RpcResult<Void> apply(RpcResult<TransactionStatus> input)

{ return Rpcs.<Void>getRpcResult(input.isSuccessful(), input.getErrors()); }

};

public Future<RpcResult<Void>>
registerEndpoint(RegisterEndpointInput input) {
WriteTransaction t = dataProvider.newWriteOnlyTransaction();

Endpoint ep = buildEndpoint(input)
.setTimestamp(timestamp)
.build();

EndpointKey key =
new EndpointKey(ep.getL2Context(), ep.getMacAddress());
InstanceIdentifier<Endpoint> iid =
InstanceIdentifier.builder(Endpoints.class)
.child(Endpoint.class, key)
.build();

t.put(LogicalDatastoreType.OPERATIONAL, iid, ep);

ListenableFuture<RpcResult<TransactionStatus>> r = t.commit();
return Futures.transform(r, futureTrans, executor);
}



 Comments   
Comment by Tony Tkacik [ 03/Jul/14 ]

remote: https://git.opendaylight.org/gerrit/8619

Comment by Rob Adams [ 03/Jul/14 ]

I tried with that patch and I still get the same error.

Comment by Rob Adams [ 03/Jul/14 ]

It works though when I add:

InstanceIdentifier<Endpoints> iid =
InstanceIdentifier.builder(Endpoints.class).build();
WriteTransaction t = this.dataProvider.newWriteOnlyTransaction();
t.put(LogicalDatastoreType.OPERATIONAL,
iid, new EndpointsBuilder().build());
ListenableFuture<RpcResult<TransactionStatus>> f = t.commit();
Futures.addCallback(f, new FutureCallback<RpcResult<TransactionStatus>>() {

@Override
public void onSuccess(RpcResult<TransactionStatus> result) {

}

@Override
public void onFailure(Throwable t)

{ LOG.error("Could not write endpoint base container", t); }

});

to my constructor.

Comment by Tony Tkacik [ 25/Jul/14 ]

Added methods put and merge which allows you to explicitly state that you want
to create parents.

Generated at Wed Feb 07 19:53:24 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.