{"action":"created","comment":{"url":"https://api.github.com/repos/neo4j/neo4j/pulls/comments/175720329","pull_request_review_id":105293783,"id":175720329,"diff_hunk":"@@ -69,70 +75,72 @@ long copyStoreFiles( CatchupAddressProvider catchupAddressProvider, StoreId expe\n     private void copyFilesIndividually( PrepareStoreCopyResponse prepareStoreCopyResponse, StoreId expectedStoreId, CatchupAddressProvider addressProvider,\n             StoreFileStreams storeFileStreams, Supplier<TerminationCondition> terminationConditions ) throws StoreCopyFailedException\n     {\n+        ExponentialBackoffStrategy exponentialBackoffStrategy = new ExponentialBackoffStrategy( 1, 1000, TimeUnit.MILLISECONDS );\n         CatchUpResponseAdaptor<StoreCopyFinishedResponse> copyHandler = new StoreFileCopyResponseAdaptor( storeFileStreams, log );\n         long lastTransactionId = prepareStoreCopyResponse.lastTransactionId();\n         for ( File file : prepareStoreCopyResponse.getFiles() )\n         {\n-            TerminationCondition terminationCondition = terminationConditions.get();\n-            boolean successful;\n-            do\n-            {\n-                try\n-                {\n-                    AdvertisedSocketAddress from = addressProvider.primary();\n-                    log.info( String.format( \"Downloading file '%s' from '%s'\", file, from ) );\n-                    StoreCopyFinishedResponse response =\n-                            catchUpClient.makeBlockingRequest( from, new GetStoreFileRequest( expectedStoreId, file, lastTransactionId ), copyHandler );\n-                    successful = successfulFileDownload( response );\n-                }\n-                catch ( CatchUpClientException | CatchupAddressResolutionException e )\n-                {\n-                    successful = false;\n-                }\n-                if ( !successful )\n-                {\n-                    log.error( \"Failed to download file '%s'\", file );\n-                    terminationCondition.assertContinue();\n-                }\n-            }\n-            while ( !successful );\n+            persistentCall( new GetStoreFileRequest( expectedStoreId, file, lastTransactionId ), copyHandler, addressProvider, terminationConditions.get(),\n+                    exponentialBackoffStrategy );\n         }\n     }\n \n     private void copyIndexSnapshotIndividually( PrepareStoreCopyResponse prepareStoreCopyResponse, StoreId expectedStoreId,\n-            CatchupAddressProvider addressProvider,\n-            StoreFileStreams storeFileStreams, Supplier<TerminationCondition> terminationConditions ) throws StoreCopyFailedException\n+            CatchupAddressProvider addressProvider, StoreFileStreams storeFileStreams, Supplier<TerminationCondition> terminationConditions )\n+            throws StoreCopyFailedException\n     {\n+        ExponentialBackoffStrategy exponentialBackoffStrategy = new ExponentialBackoffStrategy( 1, 1000, TimeUnit.MILLISECONDS );\n         CatchUpResponseAdaptor<StoreCopyFinishedResponse> copyHandler = new StoreFileCopyResponseAdaptor( storeFileStreams, log );\n         long lastTransactionId = prepareStoreCopyResponse.lastTransactionId();\n         PrimitiveLongIterator indexIds = prepareStoreCopyResponse.getIndexIds().iterator();\n         while ( indexIds.hasNext() )\n         {\n             long indexId = indexIds.next();\n-            TerminationCondition terminationCondition = terminationConditions.get();\n-            boolean successful;\n-            do\n+            persistentCall( new GetIndexFilesRequest( expectedStoreId, indexId, lastTransactionId ), copyHandler, addressProvider, terminationConditions.get(),\n+                    exponentialBackoffStrategy );\n+        }\n+    }\n+\n+    private void persistentCall( CatchUpRequest request, CatchUpResponseAdaptor<StoreCopyFinishedResponse> copyHandler, CatchupAddressProvider addressProvider,\n+            TerminationCondition terminationCondition, ExponentialBackoffStrategy exponentialBackoffStrategy ) throws StoreCopyFailedException\n+    {\n+        boolean successful;\n+        do\n+        {\n+            try\n             {\n-                try\n-                {\n-                    AdvertisedSocketAddress from = addressProvider.primary();\n-                    log.info( String.format( \"Downloading snapshot of index '%s' from '%s'\", indexId, from ) );\n-                    StoreCopyFinishedResponse response =\n-                            catchUpClient.makeBlockingRequest( from, new GetIndexFilesRequest( expectedStoreId, indexId, lastTransactionId ),\n-                                    copyHandler );\n-                    successful = successfulFileDownload( response );\n-                }\n-                catch ( CatchUpClientException | CatchupAddressResolutionException e )\n-                {\n-                    successful = false;\n-                }\n-                if ( !successful )\n-                {\n-                    log.error( \"Failed to download files from index '%s'\", indexId );\n-                    terminationCondition.assertContinue();\n-                }\n+                AdvertisedSocketAddress from = addressProvider.secondary();\n+                log.info( format( \"Sending request '%s' to '%s'\", request, from ) );\n+                StoreCopyFinishedResponse response = catchUpClient.makeBlockingRequest( from, request, copyHandler );\n+                successful = successfulFileDownload( response );\n+            }\n+            catch ( CatchUpClientException | CatchupAddressResolutionException e )\n+            {\n+                successful = false;\n+            }\n+            if ( !successful )\n+            {\n+                log.error( format( \"Request failed '%s'\", request ) );\n+                terminationCondition.assertContinue();\n+            }\n+            else\n+            {\n+                log.info( format( \"Request was successful '%s'\", request ) );\n             }\n-            while ( !successful );\n+            awaitTimeout( exponentialBackoffStrategy.newTimeout() );","path":"enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/storecopy/StoreCopyClient.java","position":129,"original_position":129,"commit_id":"4114b61bd9f95758cdb433ba2fd531699e8a9744","original_commit_id":"4114b61bd9f95758cdb433ba2fd531699e8a9744","user":{"login":"RagnarW","id":14071061,"avatar_url":"https://avatars3.githubusercontent.com/u/14071061?v=4","gravatar_id":"","url":"https://api.github.com/users/RagnarW","html_url":"https://github.com/RagnarW","followers_url":"https://api.github.com/users/RagnarW/followers","following_url":"https://api.github.com/users/RagnarW/following{/other_user}","gists_url":"https://api.github.com/users/RagnarW/gists{/gist_id}","starred_url":"https://api.github.com/users/RagnarW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RagnarW/subscriptions","organizations_url":"https://api.github.com/users/RagnarW/orgs","repos_url":"https://api.github.com/users/RagnarW/repos","events_url":"https://api.github.com/users/RagnarW/events{/privacy}","received_events_url":"https://api.github.com/users/RagnarW/received_events","type":"User","site_admin":false},"body":"I also put it in the wrong place. I'll fix this. It also hit me that I can be much smarter here depending on the response from the server. I think we only need to await on exception since a failed response from the server should mean that i should try another one.","created_at":"2018-03-20T10:41:47Z","updated_at":"2018-03-20T10:41:47Z","html_url":"https://github.com/neo4j/neo4j/pull/11264#discussion_r175720329","pull_request_url":"https://api.github.com/repos/neo4j/neo4j/pulls/11264","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/comments/175720329"},"html":{"href":"https://github.com/neo4j/neo4j/pull/11264#discussion_r175720329"},"pull_request":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/11264"}},"in_reply_to_id":175709685},"pull_request":{"url":"https://api.github.com/repos/neo4j/neo4j/pulls/11264","id":174993541,"html_url":"https://github.com/neo4j/neo4j/pull/11264","diff_url":"https://github.com/neo4j/neo4j/pull/11264.diff","patch_url":"https://github.com/neo4j/neo4j/pull/11264.patch","issue_url":"https://api.github.com/repos/neo4j/neo4j/issues/11264","number":11264,"state":"open","locked":false,"title":"3.4 storecopy upstream strategy","user":{"login":"RagnarW","id":14071061,"avatar_url":"https://avatars3.githubusercontent.com/u/14071061?v=4","gravatar_id":"","url":"https://api.github.com/users/RagnarW","html_url":"https://github.com/RagnarW","followers_url":"https://api.github.com/users/RagnarW/followers","following_url":"https://api.github.com/users/RagnarW/following{/other_user}","gists_url":"https://api.github.com/users/RagnarW/gists{/gist_id}","starred_url":"https://api.github.com/users/RagnarW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RagnarW/subscriptions","organizations_url":"https://api.github.com/users/RagnarW/orgs","repos_url":"https://api.github.com/users/RagnarW/repos","events_url":"https://api.github.com/users/RagnarW/events{/privacy}","received_events_url":"https://api.github.com/users/RagnarW/received_events","type":"User","site_admin":false},"body":"Uses upstream strategy when doing store copy.\r\n\r\nUpstream strategies are moved to a separate package so that they can be used by both cores and read replicas.\r\n\r\nRead replicas are bound to upstream strategy for any request within store copy while core prioritizes the leader when they do primary calls and uses upstream strategy for secondary calls.\r\n\r\nCores default upstream strategy is to alternate between random read replicas or cores.\r\n\r\nA change is also made to CatchupClient where it will now fail if channel is not active before sending a request to avoid unnecessary waiting for futile timeouts.","created_at":"2018-03-14T15:29:56Z","updated_at":"2018-03-20T10:41:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"51fbdf056e6e8e32a5e75fffd62df91b881fbf5a","assignee":null,"assignees":[],"requested_reviewers":[{"login":"phughk","id":6785919,"avatar_url":"https://avatars2.githubusercontent.com/u/6785919?v=4","gravatar_id":"","url":"https://api.github.com/users/phughk","html_url":"https://github.com/phughk","followers_url":"https://api.github.com/users/phughk/followers","following_url":"https://api.github.com/users/phughk/following{/other_user}","gists_url":"https://api.github.com/users/phughk/gists{/gist_id}","starred_url":"https://api.github.com/users/phughk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phughk/subscriptions","organizations_url":"https://api.github.com/users/phughk/orgs","repos_url":"https://api.github.com/users/phughk/repos","events_url":"https://api.github.com/users/phughk/events{/privacy}","received_events_url":"https://api.github.com/users/phughk/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":695463446,"url":"https://api.github.com/repos/neo4j/neo4j/labels/3.4","name":"3.4","color":"f9d0c4","default":false},{"id":291444158,"url":"https://api.github.com/repos/neo4j/neo4j/labels/causal%20clustering","name":"causal clustering","color":"207de5","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/neo4j/neo4j/pulls/11264/commits","review_comments_url":"https://api.github.com/repos/neo4j/neo4j/pulls/11264/comments","review_comment_url":"https://api.github.com/repos/neo4j/neo4j/pulls/comments{/number}","comments_url":"https://api.github.com/repos/neo4j/neo4j/issues/11264/comments","statuses_url":"https://api.github.com/repos/neo4j/neo4j/statuses/4114b61bd9f95758cdb433ba2fd531699e8a9744","head":{"label":"RagnarW:3.4-storecopy-upstream-strategy","ref":"3.4-storecopy-upstream-strategy","sha":"4114b61bd9f95758cdb433ba2fd531699e8a9744","user":{"login":"RagnarW","id":14071061,"avatar_url":"https://avatars3.githubusercontent.com/u/14071061?v=4","gravatar_id":"","url":"https://api.github.com/users/RagnarW","html_url":"https://github.com/RagnarW","followers_url":"https://api.github.com/users/RagnarW/followers","following_url":"https://api.github.com/users/RagnarW/following{/other_user}","gists_url":"https://api.github.com/users/RagnarW/gists{/gist_id}","starred_url":"https://api.github.com/users/RagnarW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RagnarW/subscriptions","organizations_url":"https://api.github.com/users/RagnarW/orgs","repos_url":"https://api.github.com/users/RagnarW/repos","events_url":"https://api.github.com/users/RagnarW/events{/privacy}","received_events_url":"https://api.github.com/users/RagnarW/received_events","type":"User","site_admin":false},"repo":{"id":110665548,"name":"neo4j","full_name":"RagnarW/neo4j","owner":{"login":"RagnarW","id":14071061,"avatar_url":"https://avatars3.githubusercontent.com/u/14071061?v=4","gravatar_id":"","url":"https://api.github.com/users/RagnarW","html_url":"https://github.com/RagnarW","followers_url":"https://api.github.com/users/RagnarW/followers","following_url":"https://api.github.com/users/RagnarW/following{/other_user}","gists_url":"https://api.github.com/users/RagnarW/gists{/gist_id}","starred_url":"https://api.github.com/users/RagnarW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RagnarW/subscriptions","organizations_url":"https://api.github.com/users/RagnarW/orgs","repos_url":"https://api.github.com/users/RagnarW/repos","events_url":"https://api.github.com/users/RagnarW/events{/privacy}","received_events_url":"https://api.github.com/users/RagnarW/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RagnarW/neo4j","description":"Graphs for Everyone","fork":true,"url":"https://api.github.com/repos/RagnarW/neo4j","forks_url":"https://api.github.com/repos/RagnarW/neo4j/forks","keys_url":"https://api.github.com/repos/RagnarW/neo4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RagnarW/neo4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RagnarW/neo4j/teams","hooks_url":"https://api.github.com/repos/RagnarW/neo4j/hooks","issue_events_url":"https://api.github.com/repos/RagnarW/neo4j/issues/events{/number}","events_url":"https://api.github.com/repos/RagnarW/neo4j/events","assignees_url":"https://api.github.com/repos/RagnarW/neo4j/assignees{/user}","branches_url":"https://api.github.com/repos/RagnarW/neo4j/branches{/branch}","tags_url":"https://api.github.com/repos/RagnarW/neo4j/tags","blobs_url":"https://api.github.com/repos/RagnarW/neo4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RagnarW/neo4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RagnarW/neo4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/RagnarW/neo4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RagnarW/neo4j/statuses/{sha}","languages_url":"https://api.github.com/repos/RagnarW/neo4j/languages","stargazers_url":"https://api.github.com/repos/RagnarW/neo4j/stargazers","contributors_url":"https://api.github.com/repos/RagnarW/neo4j/contributors","subscribers_url":"https://api.github.com/repos/RagnarW/neo4j/subscribers","subscription_url":"https://api.github.com/repos/RagnarW/neo4j/subscription","commits_url":"https://api.github.com/repos/RagnarW/neo4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/RagnarW/neo4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/RagnarW/neo4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/RagnarW/neo4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/RagnarW/neo4j/contents/{+path}","compare_url":"https://api.github.com/repos/RagnarW/neo4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RagnarW/neo4j/merges","archive_url":"https://api.github.com/repos/RagnarW/neo4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RagnarW/neo4j/downloads","issues_url":"https://api.github.com/repos/RagnarW/neo4j/issues{/number}","pulls_url":"https://api.github.com/repos/RagnarW/neo4j/pulls{/number}","milestones_url":"https://api.github.com/repos/RagnarW/neo4j/milestones{/number}","notifications_url":"https://api.github.com/repos/RagnarW/neo4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RagnarW/neo4j/labels{/name}","releases_url":"https://api.github.com/repos/RagnarW/neo4j/releases{/id}","deployments_url":"https://api.github.com/repos/RagnarW/neo4j/deployments","created_at":"2017-11-14T08:59:30Z","updated_at":"2017-11-14T09:00:04Z","pushed_at":"2018-03-19T13:57:56Z","git_url":"git://github.com/RagnarW/neo4j.git","ssh_url":"git@github.com:RagnarW/neo4j.git","clone_url":"https://github.com/RagnarW/neo4j.git","svn_url":"https://github.com/RagnarW/neo4j","homepage":"http://neo4j.com","size":394598,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"3.4"}},"base":{"label":"neo4j:3.4","ref":"3.4","sha":"d63844f6380762892f3ba1a731a52e560bc5bf83","user":{"login":"neo4j","id":201120,"avatar_url":"https://avatars3.githubusercontent.com/u/201120?v=4","gravatar_id":"","url":"https://api.github.com/users/neo4j","html_url":"https://github.com/neo4j","followers_url":"https://api.github.com/users/neo4j/followers","following_url":"https://api.github.com/users/neo4j/following{/other_user}","gists_url":"https://api.github.com/users/neo4j/gists{/gist_id}","starred_url":"https://api.github.com/users/neo4j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neo4j/subscriptions","organizations_url":"https://api.github.com/users/neo4j/orgs","repos_url":"https://api.github.com/users/neo4j/repos","events_url":"https://api.github.com/users/neo4j/events{/privacy}","received_events_url":"https://api.github.com/users/neo4j/received_events","type":"Organization","site_admin":false},"repo":{"id":6650539,"name":"neo4j","full_name":"neo4j/neo4j","owner":{"login":"neo4j","id":201120,"avatar_url":"https://avatars3.githubusercontent.com/u/201120?v=4","gravatar_id":"","url":"https://api.github.com/users/neo4j","html_url":"https://github.com/neo4j","followers_url":"https://api.github.com/users/neo4j/followers","following_url":"https://api.github.com/users/neo4j/following{/other_user}","gists_url":"https://api.github.com/users/neo4j/gists{/gist_id}","starred_url":"https://api.github.com/users/neo4j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neo4j/subscriptions","organizations_url":"https://api.github.com/users/neo4j/orgs","repos_url":"https://api.github.com/users/neo4j/repos","events_url":"https://api.github.com/users/neo4j/events{/privacy}","received_events_url":"https://api.github.com/users/neo4j/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/neo4j/neo4j","description":"Graphs for Everyone","fork":false,"url":"https://api.github.com/repos/neo4j/neo4j","forks_url":"https://api.github.com/repos/neo4j/neo4j/forks","keys_url":"https://api.github.com/repos/neo4j/neo4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/neo4j/neo4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/neo4j/neo4j/teams","hooks_url":"https://api.github.com/repos/neo4j/neo4j/hooks","issue_events_url":"https://api.github.com/repos/neo4j/neo4j/issues/events{/number}","events_url":"https://api.github.com/repos/neo4j/neo4j/events","assignees_url":"https://api.github.com/repos/neo4j/neo4j/assignees{/user}","branches_url":"https://api.github.com/repos/neo4j/neo4j/branches{/branch}","tags_url":"https://api.github.com/repos/neo4j/neo4j/tags","blobs_url":"https://api.github.com/repos/neo4j/neo4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/neo4j/neo4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/neo4j/neo4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/neo4j/neo4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/neo4j/neo4j/statuses/{sha}","languages_url":"https://api.github.com/repos/neo4j/neo4j/languages","stargazers_url":"https://api.github.com/repos/neo4j/neo4j/stargazers","contributors_url":"https://api.github.com/repos/neo4j/neo4j/contributors","subscribers_url":"https://api.github.com/repos/neo4j/neo4j/subscribers","subscription_url":"https://api.github.com/repos/neo4j/neo4j/subscription","commits_url":"https://api.github.com/repos/neo4j/neo4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/neo4j/neo4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/neo4j/neo4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/neo4j/neo4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/neo4j/neo4j/contents/{+path}","compare_url":"https://api.github.com/repos/neo4j/neo4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/neo4j/neo4j/merges","archive_url":"https://api.github.com/repos/neo4j/neo4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/neo4j/neo4j/downloads","issues_url":"https://api.github.com/repos/neo4j/neo4j/issues{/number}","pulls_url":"https://api.github.com/repos/neo4j/neo4j/pulls{/number}","milestones_url":"https://api.github.com/repos/neo4j/neo4j/milestones{/number}","notifications_url":"https://api.github.com/repos/neo4j/neo4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/neo4j/neo4j/labels{/name}","releases_url":"https://api.github.com/repos/neo4j/neo4j/releases{/id}","deployments_url":"https://api.github.com/repos/neo4j/neo4j/deployments","created_at":"2012-11-12T08:46:15Z","updated_at":"2018-03-20T10:27:59Z","pushed_at":"2018-03-20T10:41:24Z","git_url":"git://github.com/neo4j/neo4j.git","ssh_url":"git@github.com:neo4j/neo4j.git","clone_url":"https://github.com/neo4j/neo4j.git","svn_url":"https://github.com/neo4j/neo4j","homepage":"http://neo4j.com","size":394781,"stargazers_count":4841,"watchers_count":4841,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1303,"mirror_url":null,"archived":false,"open_issues_count":327,"license":null,"forks":1303,"open_issues":327,"watchers":4841,"default_branch":"3.4"}},"_links":{"self":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/11264"},"html":{"href":"https://github.com/neo4j/neo4j/pull/11264"},"issue":{"href":"https://api.github.com/repos/neo4j/neo4j/issues/11264"},"comments":{"href":"https://api.github.com/repos/neo4j/neo4j/issues/11264/comments"},"review_comments":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/11264/comments"},"review_comment":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/11264/commits"},"statuses":{"href":"https://api.github.com/repos/neo4j/neo4j/statuses/4114b61bd9f95758cdb433ba2fd531699e8a9744"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"RagnarW"}}