@@ -75,7 +75,6 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
7575 " ログが追加された後にログの長さがしきい値を超えている場合はスナップショットがとられる" in {
7676 val snapshotStore = TestProbe ()
7777 val replicationActor = TestProbe ()
78- val commitLogStore = TestProbe ()
7978 val shardId = createUniqueShardId()
8079 val followerMemberIndex = createUniqueMemberIndex()
8180 val follower = createRaftActor(
@@ -84,7 +83,6 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
8483 shardSnapshotStore = snapshotStore.ref,
8584 replicationActor = replicationActor.ref,
8685 settings = RaftSettings (raftConfig),
87- commitLogStore = commitLogStore.ref,
8886 )
8987
9088 val leaderMemberIndex = createUniqueMemberIndex()
@@ -105,10 +103,6 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
105103 leaderCommit = applicableIndex,
106104 )
107105
108- // To ensure compaction starts, CommitLogStore should handle AppendCommittedEntries.
109- commitLogStore.expectMsg(CommitLogStoreActor .AppendCommittedEntries (shardId, Seq .empty))
110- commitLogStore.reply(CommitLogStoreActor .AppendCommittedEntriesResponse (applicableIndex))
111-
112106 val command =
113107 replicationActor.fishForSpecificMessage() {
114108 case msg : TakeSnapshot => msg
@@ -375,7 +369,6 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
375369 " prevent to start snapshot synchronization during compaction" in {
376370 val snapshotStore = TestProbe ()
377371 val replicationActor = TestProbe ()
378- val commitLogStore = TestProbe ()
379372 val shardId = createUniqueShardId()
380373 val followerMemberIndex = createUniqueMemberIndex()
381374 val follower = createRaftActor(
@@ -384,7 +377,6 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
384377 shardSnapshotStore = snapshotStore.ref,
385378 replicationActor = replicationActor.ref,
386379 settings = RaftSettings (raftConfig),
387- commitLogStore = commitLogStore.ref,
388380 )
389381
390382 val leaderMemberIndex = createUniqueMemberIndex()
@@ -413,10 +405,6 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
413405 leaderCommit = applicableIndex,
414406 )
415407
416- // To ensure compaction starts, CommitLogStore should handle AppendCommittedEntries.
417- commitLogStore.expectMsg(CommitLogStoreActor .AppendCommittedEntries (shardId, Seq .empty))
418- commitLogStore.reply(CommitLogStoreActor .AppendCommittedEntriesResponse (applicableIndex))
419-
420408 // wait for starting compaction
421409 val takeSnapshot =
422410 replicationActor.fishForSpecificMessage() {
@@ -440,7 +428,6 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
440428 " not persist snapshots that have already been persisted in the next compaction" in {
441429 val snapshotStore = TestProbe ()
442430 val replicationActor = TestProbe ()
443- val commitLogStore = TestProbe ()
444431 val shardId = createUniqueShardId()
445432 val followerMemberIndex = createUniqueMemberIndex()
446433 val follower = createRaftActor(
@@ -449,7 +436,6 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
449436 shardSnapshotStore = snapshotStore.ref,
450437 replicationActor = replicationActor.ref,
451438 settings = RaftSettings (raftConfig),
452- commitLogStore = commitLogStore.ref,
453439 )
454440
455441 val leaderMemberIndex = createUniqueMemberIndex()
@@ -470,10 +456,6 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
470456 leaderCommit = LogEntryIndex (4 ),
471457 )
472458
473- // To ensure compaction starts, CommitLogStore should handle AppendCommittedEntries.
474- commitLogStore.expectMsg(CommitLogStoreActor .AppendCommittedEntries (shardId, Seq .empty))
475- commitLogStore.reply(CommitLogStoreActor .AppendCommittedEntriesResponse (LogEntryIndex (4 )))
476-
477459 replicationActor.fishForSpecificMessage() {
478460 case msg : TakeSnapshot =>
479461 msg.metadata.entityId should be(entityId1)
@@ -499,10 +481,6 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
499481 leaderCommit = LogEntryIndex (7 ),
500482 )
501483
502- // To ensure compaction starts, CommitLogStore should handle AppendCommittedEntries.
503- commitLogStore.expectMsg(CommitLogStoreActor .AppendCommittedEntries (shardId, Seq .empty))
504- commitLogStore.reply(CommitLogStoreActor .AppendCommittedEntriesResponse (LogEntryIndex (7 )))
505-
506484 // the snapshot should be only for entity2
507485 replicationActor.fishForSpecificMessage() {
508486 case msg : TakeSnapshot =>
@@ -516,16 +494,18 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
516494 }
517495 }
518496
519- " not start if the compaction might not delete enough log entries" in {
497+ " warn and continue if the compaction might not delete enough log entries" in {
520498 val commitLogStore = TestProbe ()
521499 val shardId = createUniqueShardId()
522500 val followerMemberIndex = createUniqueMemberIndex()
523501 val raftSettings = RaftSettings (raftConfig)
502+ val replicationActor = TestProbe ()
524503 val follower = createRaftActor(
525504 shardId = shardId,
526505 selfMemberIndex = followerMemberIndex,
527506 commitLogStore = commitLogStore.ref,
528507 settings = raftSettings,
508+ replicationActor = replicationActor.ref,
529509 )
530510
531511 // The compaction cannot delete any entries by setting eventSourcingIndex to 0
@@ -536,11 +516,12 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
536516 assume(raftSettings.compactionLogSizeThreshold == 3 )
537517 LoggingTestKit
538518 .warn(
539- " [Follower] Skipping compaction since compaction might not delete enough entries " +
540- " (even if this compaction continues, the remaining entries will trigger new compaction at the next tick). " +
519+ " [Follower] Compaction might not delete enough entries, but will continue to reduce log size as possible " +
520+ " (even if this compaction continues, the remaining entries might trigger new compaction at the next tick). " +
541521 " Estimated compacted log size is [3] entries (lastApplied [3], eventSourcingIndex [Some(0)], preserveLogSize [1]), " +
542522 " however compaction.log-size-threshold is [3] entries. " +
543- " This warning happens if event sourcing is too slow or compaction is too fast." ,
523+ " This warning might happen if event sourcing is too slow or compaction is too fast (or too slow). " +
524+ " If this warning continues, please consult settings related to event sourcing and compaction." ,
544525 ).expect {
545526 val leaderMemberIndex = createUniqueMemberIndex()
546527 val entityId = NormalizedEntityId .from(" entity1" )
@@ -556,11 +537,12 @@ class RaftActorSpec extends TestKit(ActorSystem()) with RaftActorSpecBase {
556537 entries = logEntries,
557538 leaderCommit = LogEntryIndex (3 ),
558539 )
559- // A few seconds later (`compaction.log-size-check-interval`),
560- // the follower will output a warn log and not start the compaction
561- // since the estimated compacted entries size is larger than the threshold (`compaction.log-size-threshold`).
562- }
563540
541+ val takeSnapshot = replicationActor.fishForSpecificMessage() {
542+ case msg : TakeSnapshot => msg
543+ }
544+ takeSnapshot.metadata shouldBe EntitySnapshotMetadata (entityId, LogEntryIndex (3 ))
545+ }
564546 }
565547
566548 }
0 commit comments