4343import org .elasticsearch .plugins .Plugin ;
4444import org .elasticsearch .snapshots .RestoreInfo ;
4545import org .elasticsearch .snapshots .RestoreService ;
46+ import org .elasticsearch .test .junit .annotations .TestIssueLogging ;
4647import org .elasticsearch .test .transport .MockTransportService ;
4748import org .elasticsearch .transport .ConnectTransportException ;
4849import org .elasticsearch .transport .RemoteTransportException ;
8687import static org .hamcrest .Matchers .greaterThan ;
8788import static org .hamcrest .Matchers .hasSize ;
8889
90+ @ TestIssueLogging (
91+ value = "org.elasticsearch.xpack.ccr:trace,org.elasticsearch.indices.recovery:trace,org.elasticsearch.index.seqno:debug" ,
92+ issueUrl = "https://github.com/elastic/elasticsearch/issues/45192" )
8993public class CcrRetentionLeaseIT extends CcrIntegTestCase {
9094
9195 public static final class RetentionLeaseRenewIntervalSettingPlugin extends Plugin {
@@ -779,6 +783,9 @@ public void testRetentionLeaseIsAddedIfItDisappearsWhileFollowing() throws Excep
779783 || TransportActionProxy .getProxyAction (RetentionLeaseActions .Renew .ACTION_NAME ).equals (action )) {
780784 senderTransportService .clearAllRules ();
781785 final RetentionLeaseActions .RenewRequest renewRequest = (RetentionLeaseActions .RenewRequest ) request ;
786+ final String retentionLeaseId = getRetentionLeaseId (followerIndex , leaderIndex );
787+ assertThat (retentionLeaseId , equalTo (renewRequest .getId ()));
788+ logger .info ("--> intercepting renewal request for retention lease [{}]" , retentionLeaseId );
782789 final String primaryShardNodeId =
783790 getLeaderCluster ()
784791 .clusterService ()
@@ -796,17 +803,17 @@ public void testRetentionLeaseIsAddedIfItDisappearsWhileFollowing() throws Excep
796803 .getShardOrNull (renewRequest .getShardId ());
797804 final CountDownLatch innerLatch = new CountDownLatch (1 );
798805 // this forces the background renewal from following to face a retention lease not found exception
799- primary . removeRetentionLease (
800- getRetentionLeaseId ( followerIndex , leaderIndex ) ,
806+ logger . info ( "--> removing retention lease [{}] on the leader" , retentionLeaseId );
807+ primary . removeRetentionLease ( retentionLeaseId ,
801808 ActionListener .wrap (r -> innerLatch .countDown (), e -> fail (e .toString ())));
802-
809+ logger . info ( "--> waiting for the removed retention lease [{}] to be synced on the leader" , retentionLeaseId );
803810 try {
804811 innerLatch .await ();
805812 } catch (final InterruptedException e ) {
806813 Thread .currentThread ().interrupt ();
807814 fail (e .toString ());
808815 }
809-
816+ logger . info ( "--> removed retention lease [{}] on the leader" , retentionLeaseId );
810817 latch .countDown ();
811818 }
812819 connection .sendRequest (requestId , action , request , options );
@@ -877,6 +884,7 @@ public void testPeriodicRenewalDoesNotAddRetentionLeaseAfterUnfollow() throws Ex
877884 if (RetentionLeaseActions .Renew .ACTION_NAME .equals (action )
878885 || TransportActionProxy .getProxyAction (RetentionLeaseActions .Renew .ACTION_NAME ).equals (action )) {
879886 final String retentionLeaseId = getRetentionLeaseId (followerIndex , leaderIndex );
887+ logger .info ("--> blocking renewal request for retention lease [{}] until unfollowed" , retentionLeaseId );
880888 try {
881889 removeLeaseLatch .countDown ();
882890 unfollowLatch .await ();
0 commit comments