leaking transactions in ConsistentKeyLocker


Madhan Neethiraj <mneet...@...>
 

Transactions created in ConsistentKeyLocker.overrideTimestamp() are neither committed or rolled back by the callers. This results in leaked transactions. This issue (of leaked transactions) was seen while implementing a custom StoreManager. Addressing the issue required updating ConsistentKeyLocker, to commit the created transactions.

The fix is straight forward, and I have patches for master and v0.5.1. Can someone please review and either confirm the issue or suggest alternate (to avoid leaked transactions)?

Relevant code from ConsistentKeyLocker.java is given below.

Thanks,
Madhan

  private WriteResult tryWriteLockOnce(StaticBuffer key, StaticBuffer del, StoreTransaction txh) {
    ...
    try {
      final StoreTransaction newTx = overrideTimestamp(txh, writeTimer.getStartTime());
      store.mutate(key, Collections.singletonList(newLockEntry),
          null == del ? KeyColumnValueStore.NO_DELETIONS : Collections.singletonList(del), newTx);
      } catch (BackendException e) {
        ...
  }

  private WriteResult tryDeleteLockOnce(StaticBuffer key, StaticBuffer col, StoreTransaction txh) {
    ...
    try {
      final StoreTransaction newTx = overrideTimestamp(txh, delTimer.getStartTime());
      store.mutate(key, ImmutableList.of(), Collections.singletonList(col), newTx);
    } catch (BackendException e) {
      ...
  }

  protected void deleteSingleLock(KeyColumn kc, ConsistentKeyLockStatus ls, StoreTransaction tx) {
    ...
    try {
      StoreTransaction newTx = overrideTimestamp(tx, times.getTime());
      store.mutate(serializer.toLockKey(kc.getKey(), kc.getColumn()), ImmutableList.of(), deletions, newTx);
      return;
    } catch (TemporaryBackendException e) {
      ...
  }

  private StoreTransaction overrideTimestamp(final StoreTransaction tx, final Instant commitTime) throws BackendException {
    StandardBaseTransactionConfig newCfg = new StandardBaseTransactionConfig.Builder(tx.getConfiguration()).commitTime(commitTime).build();
    return manager.beginTransaction(newCfg);
  }

Join janusgraph-users@lists.lfaidata.foundation to automatically receive all group messages.