{"action":"created","comment":{"url":"https://api.github.com/repos/neo4j/neo4j/pulls/comments/65541664","id":65541664,"diff_hunk":"@@ -117,24 +114,42 @@ public synchronized void notifyCommitted( long commitIndex )\n     private void submitApplyJob( long lastToApply )\n     {\n         applier.submit( ( status ) -> () -> {\n-            try ( RaftLogCursor cursor = raftLog.getEntryCursor( lastApplied + 1 ) )\n+            try ( LogEntrySupplier cacheLogEntrySupplier = new CacheApplier();\n+                    LogEntrySupplier cursorLogEntrySupplier = new CursorApplier() )\n             {\n-                lastApplyingStorage.persistStoreData( lastToApply );\n-\n-                while ( cursor.index() < lastToApply && cursor.next() )\n+                LogEntrySupplier currentLogEntrySupplier = cacheLogEntrySupplier;\n+                for ( long i = lastApplied + 1; i < lastToApply; i++ )\n                 {\n-                    if ( cursor.get().content() instanceof DistributedOperation )\n+                    lastApplyingStorage.persistStoreData( lastToApply );\n+                    RaftLogEntry raftLogEntry = currentLogEntrySupplier.get( i );\n+                    if ( raftLogEntry == null )\n                     {\n-                        DistributedOperation distributedOperation = (DistributedOperation) cursor.get().content();\n-\n-                        progressTracker.trackReplication( distributedOperation );\n-                        handleOperation( cursor.index(), distributedOperation );\n+                        if ( currentLogEntrySupplier == cursorLogEntrySupplier )\n+                        {\n+                            throw new IllegalStateException(\n+                                    format( \"Index %d not found in the raft log. lastToApply was: %d, append index \" +\n+                                            \"is %d\", i, lastToApply, raftLog.appendIndex() ) );\n+                        }\n+                        currentLogEntrySupplier = cursorLogEntrySupplier;\n+                        raftLogEntry = currentLogEntrySupplier.get( i );\n+                    }\n \n-                        maybeFlush();\n+                    if ( raftLogEntry == null )\n+                    {\n+                        String failureMessage = format(\n+                                \"Log entry at index %d is not present in the log. Please perform recovery by \" +\n+                                        \"restarting this database instance. Indexes to be applied are %d up to %d, \" +\n+                                        \"append index is %d, prev index is %d.\",\n+                                i, lastApplied + 1, lastToApply, raftLog.appendIndex(), raftLog.prevIndex() );\n+                        log.error( failureMessage );\n+                        throw new IllegalStateException( failureMessage );","path":"enterprise/core-edge/src/main/java/org/neo4j/coreedge/raft/state/CoreState.java","position":111,"original_position":111,"commit_id":"2444116dbf72cff63ed0adee0f6d75b76510d33d","original_commit_id":"2444116dbf72cff63ed0adee0f6d75b76510d33d","user":{"login":"davidegrohmann","id":6573166,"avatar_url":"https://avatars.githubusercontent.com/u/6573166?v=3","gravatar_id":"","url":"https://api.github.com/users/davidegrohmann","html_url":"https://github.com/davidegrohmann","followers_url":"https://api.github.com/users/davidegrohmann/followers","following_url":"https://api.github.com/users/davidegrohmann/following{/other_user}","gists_url":"https://api.github.com/users/davidegrohmann/gists{/gist_id}","starred_url":"https://api.github.com/users/davidegrohmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidegrohmann/subscriptions","organizations_url":"https://api.github.com/users/davidegrohmann/orgs","repos_url":"https://api.github.com/users/davidegrohmann/repos","events_url":"https://api.github.com/users/davidegrohmann/events{/privacy}","received_events_url":"https://api.github.com/users/davidegrohmann/received_events","type":"User","site_admin":false},"body":"let's clean up this code it is really hard to read","created_at":"2016-06-02T13:46:42Z","updated_at":"2016-06-02T13:46:42Z","html_url":"https://github.com/neo4j/neo4j/pull/7171#discussion_r65541664","pull_request_url":"https://api.github.com/repos/neo4j/neo4j/pulls/7171","_links":{"self":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/comments/65541664"},"html":{"href":"https://github.com/neo4j/neo4j/pull/7171#discussion_r65541664"},"pull_request":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/7171"}}},"pull_request":{"url":"https://api.github.com/repos/neo4j/neo4j/pulls/7171","id":70683780,"html_url":"https://github.com/neo4j/neo4j/pull/7171","diff_url":"https://github.com/neo4j/neo4j/pull/7171.diff","patch_url":"https://github.com/neo4j/neo4j/pull/7171.patch","issue_url":"https://api.github.com/repos/neo4j/neo4j/issues/7171","number":7171,"state":"open","locked":false,"title":"Introduce cache to hold uncommitted log entries.","user":{"login":"maxsumrall","id":628843,"avatar_url":"https://avatars.githubusercontent.com/u/628843?v=3","gravatar_id":"","url":"https://api.github.com/users/maxsumrall","html_url":"https://github.com/maxsumrall","followers_url":"https://api.github.com/users/maxsumrall/followers","following_url":"https://api.github.com/users/maxsumrall/following{/other_user}","gists_url":"https://api.github.com/users/maxsumrall/gists{/gist_id}","starred_url":"https://api.github.com/users/maxsumrall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxsumrall/subscriptions","organizations_url":"https://api.github.com/users/maxsumrall/orgs","repos_url":"https://api.github.com/users/maxsumrall/repos","events_url":"https://api.github.com/users/maxsumrall/events{/privacy}","received_events_url":"https://api.github.com/users/maxsumrall/received_events","type":"User","site_admin":false},"body":" Log entries which are uncommitted and waiting for cluster members to\r\n receive the entry are stashed in the cache for the commit step.","created_at":"2016-05-19T12:17:30Z","updated_at":"2016-06-02T13:46:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93b19e8b2a06a253cbff6529ee84bd8c3f80951e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/neo4j/neo4j/pulls/7171/commits","review_comments_url":"https://api.github.com/repos/neo4j/neo4j/pulls/7171/comments","review_comment_url":"https://api.github.com/repos/neo4j/neo4j/pulls/comments{/number}","comments_url":"https://api.github.com/repos/neo4j/neo4j/issues/7171/comments","statuses_url":"https://api.github.com/repos/neo4j/neo4j/statuses/2444116dbf72cff63ed0adee0f6d75b76510d33d","head":{"label":"maxsumrall:3.1-raft-log-caching","ref":"3.1-raft-log-caching","sha":"2444116dbf72cff63ed0adee0f6d75b76510d33d","user":{"login":"maxsumrall","id":628843,"avatar_url":"https://avatars.githubusercontent.com/u/628843?v=3","gravatar_id":"","url":"https://api.github.com/users/maxsumrall","html_url":"https://github.com/maxsumrall","followers_url":"https://api.github.com/users/maxsumrall/followers","following_url":"https://api.github.com/users/maxsumrall/following{/other_user}","gists_url":"https://api.github.com/users/maxsumrall/gists{/gist_id}","starred_url":"https://api.github.com/users/maxsumrall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxsumrall/subscriptions","organizations_url":"https://api.github.com/users/maxsumrall/orgs","repos_url":"https://api.github.com/users/maxsumrall/repos","events_url":"https://api.github.com/users/maxsumrall/events{/privacy}","received_events_url":"https://api.github.com/users/maxsumrall/received_events","type":"User","site_admin":false},"repo":{"id":44317587,"name":"neo4j","full_name":"maxsumrall/neo4j","owner":{"login":"maxsumrall","id":628843,"avatar_url":"https://avatars.githubusercontent.com/u/628843?v=3","gravatar_id":"","url":"https://api.github.com/users/maxsumrall","html_url":"https://github.com/maxsumrall","followers_url":"https://api.github.com/users/maxsumrall/followers","following_url":"https://api.github.com/users/maxsumrall/following{/other_user}","gists_url":"https://api.github.com/users/maxsumrall/gists{/gist_id}","starred_url":"https://api.github.com/users/maxsumrall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxsumrall/subscriptions","organizations_url":"https://api.github.com/users/maxsumrall/orgs","repos_url":"https://api.github.com/users/maxsumrall/repos","events_url":"https://api.github.com/users/maxsumrall/events{/privacy}","received_events_url":"https://api.github.com/users/maxsumrall/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maxsumrall/neo4j","description":"Graphs for Everyone","fork":true,"url":"https://api.github.com/repos/maxsumrall/neo4j","forks_url":"https://api.github.com/repos/maxsumrall/neo4j/forks","keys_url":"https://api.github.com/repos/maxsumrall/neo4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maxsumrall/neo4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maxsumrall/neo4j/teams","hooks_url":"https://api.github.com/repos/maxsumrall/neo4j/hooks","issue_events_url":"https://api.github.com/repos/maxsumrall/neo4j/issues/events{/number}","events_url":"https://api.github.com/repos/maxsumrall/neo4j/events","assignees_url":"https://api.github.com/repos/maxsumrall/neo4j/assignees{/user}","branches_url":"https://api.github.com/repos/maxsumrall/neo4j/branches{/branch}","tags_url":"https://api.github.com/repos/maxsumrall/neo4j/tags","blobs_url":"https://api.github.com/repos/maxsumrall/neo4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maxsumrall/neo4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maxsumrall/neo4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/maxsumrall/neo4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maxsumrall/neo4j/statuses/{sha}","languages_url":"https://api.github.com/repos/maxsumrall/neo4j/languages","stargazers_url":"https://api.github.com/repos/maxsumrall/neo4j/stargazers","contributors_url":"https://api.github.com/repos/maxsumrall/neo4j/contributors","subscribers_url":"https://api.github.com/repos/maxsumrall/neo4j/subscribers","subscription_url":"https://api.github.com/repos/maxsumrall/neo4j/subscription","commits_url":"https://api.github.com/repos/maxsumrall/neo4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/maxsumrall/neo4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/maxsumrall/neo4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/maxsumrall/neo4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/maxsumrall/neo4j/contents/{+path}","compare_url":"https://api.github.com/repos/maxsumrall/neo4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maxsumrall/neo4j/merges","archive_url":"https://api.github.com/repos/maxsumrall/neo4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maxsumrall/neo4j/downloads","issues_url":"https://api.github.com/repos/maxsumrall/neo4j/issues{/number}","pulls_url":"https://api.github.com/repos/maxsumrall/neo4j/pulls{/number}","milestones_url":"https://api.github.com/repos/maxsumrall/neo4j/milestones{/number}","notifications_url":"https://api.github.com/repos/maxsumrall/neo4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maxsumrall/neo4j/labels{/name}","releases_url":"https://api.github.com/repos/maxsumrall/neo4j/releases{/id}","deployments_url":"https://api.github.com/repos/maxsumrall/neo4j/deployments","created_at":"2015-10-15T12:58:50Z","updated_at":"2015-10-15T12:59:31Z","pushed_at":"2016-06-02T13:25:51Z","git_url":"git://github.com/maxsumrall/neo4j.git","ssh_url":"git@github.com:maxsumrall/neo4j.git","clone_url":"https://github.com/maxsumrall/neo4j.git","svn_url":"https://github.com/maxsumrall/neo4j","homepage":"http://neo4j.com","size":299808,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"2.3"}},"base":{"label":"neo4j:3.1","ref":"3.1","sha":"6113a2b32f146d62c6bd96de441a16ebaf1ffed0","user":{"login":"neo4j","id":201120,"avatar_url":"https://avatars.githubusercontent.com/u/201120?v=3","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://avatars.githubusercontent.com/u/201120?v=3","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":"2016-06-02T05:52:09Z","pushed_at":"2016-06-02T13:35:13Z","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":365069,"stargazers_count":2647,"watchers_count":2647,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":930,"mirror_url":null,"open_issues_count":371,"forks":930,"open_issues":371,"watchers":2647,"default_branch":"3.1"}},"_links":{"self":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/7171"},"html":{"href":"https://github.com/neo4j/neo4j/pull/7171"},"issue":{"href":"https://api.github.com/repos/neo4j/neo4j/issues/7171"},"comments":{"href":"https://api.github.com/repos/neo4j/neo4j/issues/7171/comments"},"review_comments":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/7171/comments"},"review_comment":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/7171/commits"},"statuses":{"href":"https://api.github.com/repos/neo4j/neo4j/statuses/2444116dbf72cff63ed0adee0f6d75b76510d33d"}}}}
{"actor":{"display_login":"davidegrohmann"}}