Skip to content

Comments

[Transaction] Transaction timeout implementation.#8750

Closed
congbobo184 wants to merge 15 commits intoapache:masterfrom
congbobo184:congbobo184_transaction_timeout_implementation
Closed

[Transaction] Transaction timeout implementation.#8750
congbobo184 wants to merge 15 commits intoapache:masterfrom
congbobo184:congbobo184_transaction_timeout_implementation

Conversation

@congbobo184
Copy link
Contributor

Motivation

in order to handle the transaction timeout.

when aborting and committing finish we should change the status in transaction coordinator.

implement

  1. add the transaction timeout tracker factory
  2. add the transaction timeout tracker
  3. use HashedWheelTimer to implement it.

Verifying this change

Add the tests for it

Does this pull request potentially affect one of the following parts:
If yes was chosen, please highlight the changes

Dependencies (does it add or upgrade a dependency): (no)
The public API: (no)
The schema: (no)
The default values of configurations: (no)
The wire protocol: (no)
The rest endpoints: (no)
The admin cli options: (no)
Anything that affects deployment: (no)

congbo added 15 commits November 26, 2020 15:46
# Conflicts:
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBufferProvider.java
…tion_timeout_implementation

# Conflicts:
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/TransactionMetadataStoreService.java
#	pulsar-broker/src/test/java/org/apache/pulsar/broker/service/TransactionMetadataStoreServiceTest.java
#	pulsar-transaction/coordinator/src/main/java/org/apache/pulsar/transaction/coordinator/TransactionMetadataStoreProvider.java
#	pulsar-transaction/coordinator/src/main/java/org/apache/pulsar/transaction/coordinator/impl/InMemTransactionMetadataStoreProvider.java
#	pulsar-transaction/coordinator/src/main/java/org/apache/pulsar/transaction/coordinator/impl/MLTransactionMetadataStoreProvider.java
#	pulsar-transaction/coordinator/src/test/java/org/apache/pulsar/transaction/coordinator/MLTransactionMetadataStoreTest.java
@congbobo184
Copy link
Contributor Author

/pulsarbot run-failure-checks

1 similar comment
@congbobo184
Copy link
Contributor Author

/pulsarbot run-failure-checks

} else {
String[] strings = positionString.split(":");
if (strings.length != 2) {
throw new IndexOutOfBoundsException();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a message ? like "invalid position "+positionString
it will ease debugging issues in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, it is a good idea!

throw new IndexOutOfBoundsException();
}
long ledgerId = Long.parseLong(strings[0]);
long entryId = Long.parseLong(strings[1]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please catch "NumberFormatException" and then rethrow a meaningful error message ?

messageIdList.add(new MessageIdImpl(
messageIdData.getLedgerId(), messageIdData.getEntryId(), messageIdData.getPartition()));
messageIdData.recycle();
//TODO when pending ack buffer finish this logic can remove
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we link an issue for this TODO ?

});
} catch (Exception e) {
resultFuture.completeExceptionally(e);
private void finalityEndTransaction(TxnID txnID, TxnStatus newStatus, TxnStatus expectedStatus) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about renaming "finalityEndTransaction" to "completeEndTransaction" ?

}
this.cursor = managedLedger.newNonDurableCursor(currentLoadPosition);

new Thread(() -> new TopicTransactionBufferReplayer(new TransactionBufferReplayCallback() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we give a name to this thread ?
probably it should be marked as "deamon"
we should also ensure that the thread ends when we are shutting down this TopicTransactionBuffer
otherwise we will have a zoombie thread that is still retaining references to this object and possibly corrupting its status.

one question isn't it too heavyweight to start a thread per each topic ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you are right. we should control the thread start and close.

one question isn't it too heavyweight to start a thread per each topic ?

we async init TopicTransactionBuffer, do you have any better way to do it?

positionsSort.add((PositionImpl) position);
}
}
}).start()).start();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not start a Thread in a constructor, especially when the Thread refers to the object that is beeing created, we could have bad memory leaks in case we are not properly releasing all of the resources

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is good idea, i will change it. :)

@congbobo184
Copy link
Contributor Author

@eolivelli thank for you comment :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants