rpuch commented on code in PR #1331:
URL: https://github.com/apache/ignite-3/pull/1331#discussion_r1021353381
##########
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:
In JRaft, the first entry in log (index=1, term=1) is always a
configuration. So, if at least 1 log entry is applied,
`committedGroupConfiguration()` will be non-null. Also, a leader might with to
install a snapshot only if it is ahead of a follower, so it has something
applied, so in this code the returned config` is never null.
I replaced the check with an assertion. WDYT?
--
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]