TransactionChains require single-threaded access, most notably
their close() contract requires that there be no outstanding
transactions.
There is a slight possibility of us violating this contract by
invoking close() while there is some command processing going
on.
Make sure we are properly synchronized when invoking the close()
call.
Change-Id: Idacc7096af448dc3a935ca3aa7ea2452bbd0135e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
@GuardedBy("this")
private final Queue<Entry<ReadWriteTransaction, TransactionCommand>> pendingTransactions = new ArrayDeque<>();
-
+ @GuardedBy("this")
private BindingTransactionChain chain;
public TransactionInvokerImpl(final DataBroker db) {
@Override
public void close() throws InterruptedException {
- this.chain.close();
this.executor.shutdown();
+
+ synchronized (this) {
+ this.chain.close();
+ }
+
if (!this.executor.awaitTermination(1, TimeUnit.SECONDS)) {
runTask.set(false);
this.executor.shutdownNow();