ibessonov commented on code in PR #1331:
URL: https://github.com/apache/ignite-3/pull/1331#discussion_r1021384428
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/snapshot/outgoing/OutgoingSnapshot.java:
##########
@@ -143,24 +141,36 @@ public PartitionKey partitionKey() {
/**
* Freezes the scope of this snapshot. This includes taking snapshot
metadata and opening TX data cursor.
- *
- * <p>Must be called under snapshot lock.
*/
- void freezeScope() {
- assert mvOperationsLock.isLocked() : "MV operations lock must be
acquired!";
+ void freezeScopeUnderMvLock() {
+ acquireMvLock();
- frozenMeta = takeSnapshotMeta();
+ try {
+ frozenMeta = takeSnapshotMeta();
- txDataCursor = partition.txStatePartitionStorage().scan();
+ txDataCursor = partition.txStatePartitionStorage().scan();
+ } finally {
+ releaseMvLock();
+ }
}
private SnapshotMeta takeSnapshotMeta() {
- long lastAppliedIndex = Math.max(
- partition.mvPartitionStorage().lastAppliedIndex(),
- partition.txStatePartitionStorage().lastAppliedIndex()
- );
+ long lastAppliedIndex;
+ long lastAppliedTerm;
- return SnapshotMetaUtils.snapshotMetaAt(lastAppliedIndex, logManager);
+ if (partition.mvPartitionStorage().lastAppliedIndex() >=
partition.txStatePartitionStorage().lastAppliedIndex()) {
+ lastAppliedIndex =
partition.mvPartitionStorage().lastAppliedIndex();
+ lastAppliedTerm = partition.mvPartitionStorage().lastAppliedTerm();
+ } else {
+ lastAppliedIndex =
partition.txStatePartitionStorage().lastAppliedIndex();
+ lastAppliedTerm =
partition.txStatePartitionStorage().lastAppliedTerm();
+ }
+
+ return SnapshotMetaUtils.snapshotMetaAt(
+ lastAppliedIndex,
+ lastAppliedTerm,
+
requireNonNull(partition.mvPartitionStorage().committedGroupConfiguration())
Review Comment:
Assertion fits better, I agree
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]