{"action":"created","comment":{"url":"https://api.github.com/repos/Graylog2/graylog2-server/pulls/comments/92844502","pull_request_review_id":13368121,"id":92844502,"diff_hunk":"@@ -97,16 +99,19 @@ public DeflectorSummary deflector(@ApiParam(name = \"indexSetId\") @PathParam(\"ind\n     @AuditEvent(type = AuditEventTypes.ES_WRITE_INDEX_UPDATE_JOB_START)\n     @Deprecated\n     public void deprecatedCycle() {\n-        final IndexSet indexSet = indexSetRegistry.getDefault()\n-                .orElseThrow(() -> new NotFoundException(\"Default index set not found\"));\n+        try {\n+            final IndexSet indexSet = indexSetRegistry.getDefault();\n \n-        checkCycle(indexSet);\n+            checkCycle(indexSet);\n \n-        final String msg = \"Cycling deflector for default index set <\" + indexSet.getConfig().id()  + \">. Reason: REST request.\";\n-        LOG.info(msg);\n-        activityWriter.write(new Activity(msg, DeflectorResource.class));\n+            final String msg = \"Cycling deflector for default index set <\" + indexSet.getConfig().id() + \">. Reason: REST request.\";\n+            LOG.info(msg);\n+            activityWriter.write(new Activity(msg, DeflectorResource.class));\n \n-        indexSet.cycle();\n+            indexSet.cycle();\n+        } catch (IllegalStateException e) {\n+            throw new NotFoundException(\"Default index set not found\");","path":"graylog2-server/src/main/java/org/graylog2/rest/resources/system/DeflectorResource.java","position":39,"original_position":39,"commit_id":"e0c4c987a5f915b990300f8742c0ee09f125d6d4","original_commit_id":"e0c4c987a5f915b990300f8742c0ee09f125d6d4","user":{"login":"joschi","id":43951,"avatar_url":"https://avatars.githubusercontent.com/u/43951?v=3","gravatar_id":"","url":"https://api.github.com/users/joschi","html_url":"https://github.com/joschi","followers_url":"https://api.github.com/users/joschi/followers","following_url":"https://api.github.com/users/joschi/following{/other_user}","gists_url":"https://api.github.com/users/joschi/gists{/gist_id}","starred_url":"https://api.github.com/users/joschi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joschi/subscriptions","organizations_url":"https://api.github.com/users/joschi/orgs","repos_url":"https://api.github.com/users/joschi/repos","events_url":"https://api.github.com/users/joschi/events{/privacy}","received_events_url":"https://api.github.com/users/joschi/received_events","type":"User","site_admin":false},"body":"I would throw an `InternalServerErrorException` here (or simply let the `IllegalStateException` bubble up which results in the same) because it's actually an error in the Graylog system, not a wrong request by the client.","created_at":"2016-12-16T16:45:05Z","updated_at":"2016-12-16T16:45:47Z","html_url":"https://github.com/Graylog2/graylog2-server/pull/3209#discussion_r92844502","pull_request_url":"https://api.github.com/repos/Graylog2/graylog2-server/pulls/3209","_links":{"self":{"href":"https://api.github.com/repos/Graylog2/graylog2-server/pulls/comments/92844502"},"html":{"href":"https://github.com/Graylog2/graylog2-server/pull/3209#discussion_r92844502"},"pull_request":{"href":"https://api.github.com/repos/Graylog2/graylog2-server/pulls/3209"}}},"pull_request":{"url":"https://api.github.com/repos/Graylog2/graylog2-server/pulls/3209","id":98128627,"html_url":"https://github.com/Graylog2/graylog2-server/pull/3209","diff_url":"https://github.com/Graylog2/graylog2-server/pull/3209.diff","patch_url":"https://github.com/Graylog2/graylog2-server/pull/3209.patch","issue_url":"https://api.github.com/repos/Graylog2/graylog2-server/issues/3209","number":3209,"state":"open","locked":false,"title":"IndexSet default setting","user":{"login":"bernd","id":461,"avatar_url":"https://avatars.githubusercontent.com/u/461?v=3","gravatar_id":"","url":"https://api.github.com/users/bernd","html_url":"https://github.com/bernd","followers_url":"https://api.github.com/users/bernd/followers","following_url":"https://api.github.com/users/bernd/following{/other_user}","gists_url":"https://api.github.com/users/bernd/gists{/gist_id}","starred_url":"https://api.github.com/users/bernd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bernd/subscriptions","organizations_url":"https://api.github.com/users/bernd/orgs","repos_url":"https://api.github.com/users/bernd/repos","events_url":"https://api.github.com/users/bernd/events{/privacy}","received_events_url":"https://api.github.com/users/bernd/received_events","type":"User","site_admin":false},"body":"An index set can be marked as `default` in `IndexSetConfig`. This cannot be changed by the user at the moment, but should be. We have to ensure that only one index set is the default!\r\n\r\nSince we are using MongoDB, there are no cross-document atomic operations or transactions so we have to take care of that ourselves.\r\n\r\n## Idea 1: Use a timestamp\r\n\r\nWe are currently using a boolean `default` field in the `index_sets` database collection to mark the default index set. Because of the lack of transactions this is not really safe to update for several documents at once. (set `true` on the new default, set `false` on all others)\r\n\r\nAs an alternative to the boolean flag we could use a timestamp field like `default_since` or similar that will be set to the current time when a \"set default index set\" request comes in. To determine the default we have to load the index set with the newest timestamp. By using a unique index on the timestamp field, we would avoid duplicate timestamps.\r\n\r\n## Idea 2: Coordinate on master\r\n\r\nAnother idea was to publish an event on the cluster event bus to set the default index set. All nodes subscribe to the event but only the master node will actually handle it. Since only one node **should** be master and the events are not processed in parallel, this should avoid interleaving writes to the index sets collection. It doesn't guarantee any order though.\r\n\r\nThis is more complicated than the timestamp idea beacuse it involves the cluster event bus and needs an event handler. It also makes the request to set the default index set async so we have to deal with that in the UI. It also fails when there is more than one active master node.\r\n\r\n## Other Ideas?\r\n\r\nPlease let me know if you have different, better ideas. Let's discuss!","created_at":"2016-12-15T11:00:54Z","updated_at":"2016-12-16T16:45:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aeadeaf1057751507a229c1de462e0b290861c68","assignee":{"login":"joschi","id":43951,"avatar_url":"https://avatars.githubusercontent.com/u/43951?v=3","gravatar_id":"","url":"https://api.github.com/users/joschi","html_url":"https://github.com/joschi","followers_url":"https://api.github.com/users/joschi/followers","following_url":"https://api.github.com/users/joschi/following{/other_user}","gists_url":"https://api.github.com/users/joschi/gists{/gist_id}","starred_url":"https://api.github.com/users/joschi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joschi/subscriptions","organizations_url":"https://api.github.com/users/joschi/orgs","repos_url":"https://api.github.com/users/joschi/repos","events_url":"https://api.github.com/users/joschi/events{/privacy}","received_events_url":"https://api.github.com/users/joschi/received_events","type":"User","site_admin":false},"assignees":[{"login":"joschi","id":43951,"avatar_url":"https://avatars.githubusercontent.com/u/43951?v=3","gravatar_id":"","url":"https://api.github.com/users/joschi","html_url":"https://github.com/joschi","followers_url":"https://api.github.com/users/joschi/followers","following_url":"https://api.github.com/users/joschi/following{/other_user}","gists_url":"https://api.github.com/users/joschi/gists{/gist_id}","starred_url":"https://api.github.com/users/joschi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joschi/subscriptions","organizations_url":"https://api.github.com/users/joschi/orgs","repos_url":"https://api.github.com/users/joschi/repos","events_url":"https://api.github.com/users/joschi/events{/privacy}","received_events_url":"https://api.github.com/users/joschi/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/Graylog2/graylog2-server/milestones/56","html_url":"https://github.com/Graylog2/graylog2-server/milestone/56","labels_url":"https://api.github.com/repos/Graylog2/graylog2-server/milestones/56/labels","id":1905276,"number":56,"title":"2.2.0","description":"Next feature release of Graylog.","creator":{"login":"bernd","id":461,"avatar_url":"https://avatars.githubusercontent.com/u/461?v=3","gravatar_id":"","url":"https://api.github.com/users/bernd","html_url":"https://github.com/bernd","followers_url":"https://api.github.com/users/bernd/followers","following_url":"https://api.github.com/users/bernd/following{/other_user}","gists_url":"https://api.github.com/users/bernd/gists{/gist_id}","starred_url":"https://api.github.com/users/bernd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bernd/subscriptions","organizations_url":"https://api.github.com/users/bernd/orgs","repos_url":"https://api.github.com/users/bernd/repos","events_url":"https://api.github.com/users/bernd/events{/privacy}","received_events_url":"https://api.github.com/users/bernd/received_events","type":"User","site_admin":false},"open_issues":61,"closed_issues":186,"state":"open","created_at":"2016-07-26T15:59:45Z","updated_at":"2016-12-16T16:28:06Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/Graylog2/graylog2-server/pulls/3209/commits","review_comments_url":"https://api.github.com/repos/Graylog2/graylog2-server/pulls/3209/comments","review_comment_url":"https://api.github.com/repos/Graylog2/graylog2-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Graylog2/graylog2-server/issues/3209/comments","statuses_url":"https://api.github.com/repos/Graylog2/graylog2-server/statuses/e0c4c987a5f915b990300f8742c0ee09f125d6d4","head":{"label":"Graylog2:default-index-set-option","ref":"default-index-set-option","sha":"e0c4c987a5f915b990300f8742c0ee09f125d6d4","user":{"login":"Graylog2","id":474892,"avatar_url":"https://avatars.githubusercontent.com/u/474892?v=3","gravatar_id":"","url":"https://api.github.com/users/Graylog2","html_url":"https://github.com/Graylog2","followers_url":"https://api.github.com/users/Graylog2/followers","following_url":"https://api.github.com/users/Graylog2/following{/other_user}","gists_url":"https://api.github.com/users/Graylog2/gists{/gist_id}","starred_url":"https://api.github.com/users/Graylog2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Graylog2/subscriptions","organizations_url":"https://api.github.com/users/Graylog2/orgs","repos_url":"https://api.github.com/users/Graylog2/repos","events_url":"https://api.github.com/users/Graylog2/events{/privacy}","received_events_url":"https://api.github.com/users/Graylog2/received_events","type":"Organization","site_admin":false},"repo":{"id":671825,"name":"graylog2-server","full_name":"Graylog2/graylog2-server","owner":{"login":"Graylog2","id":474892,"avatar_url":"https://avatars.githubusercontent.com/u/474892?v=3","gravatar_id":"","url":"https://api.github.com/users/Graylog2","html_url":"https://github.com/Graylog2","followers_url":"https://api.github.com/users/Graylog2/followers","following_url":"https://api.github.com/users/Graylog2/following{/other_user}","gists_url":"https://api.github.com/users/Graylog2/gists{/gist_id}","starred_url":"https://api.github.com/users/Graylog2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Graylog2/subscriptions","organizations_url":"https://api.github.com/users/Graylog2/orgs","repos_url":"https://api.github.com/users/Graylog2/repos","events_url":"https://api.github.com/users/Graylog2/events{/privacy}","received_events_url":"https://api.github.com/users/Graylog2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Graylog2/graylog2-server","description":"Free and open source log management","fork":false,"url":"https://api.github.com/repos/Graylog2/graylog2-server","forks_url":"https://api.github.com/repos/Graylog2/graylog2-server/forks","keys_url":"https://api.github.com/repos/Graylog2/graylog2-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Graylog2/graylog2-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Graylog2/graylog2-server/teams","hooks_url":"https://api.github.com/repos/Graylog2/graylog2-server/hooks","issue_events_url":"https://api.github.com/repos/Graylog2/graylog2-server/issues/events{/number}","events_url":"https://api.github.com/repos/Graylog2/graylog2-server/events","assignees_url":"https://api.github.com/repos/Graylog2/graylog2-server/assignees{/user}","branches_url":"https://api.github.com/repos/Graylog2/graylog2-server/branches{/branch}","tags_url":"https://api.github.com/repos/Graylog2/graylog2-server/tags","blobs_url":"https://api.github.com/repos/Graylog2/graylog2-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Graylog2/graylog2-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Graylog2/graylog2-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Graylog2/graylog2-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Graylog2/graylog2-server/statuses/{sha}","languages_url":"https://api.github.com/repos/Graylog2/graylog2-server/languages","stargazers_url":"https://api.github.com/repos/Graylog2/graylog2-server/stargazers","contributors_url":"https://api.github.com/repos/Graylog2/graylog2-server/contributors","subscribers_url":"https://api.github.com/repos/Graylog2/graylog2-server/subscribers","subscription_url":"https://api.github.com/repos/Graylog2/graylog2-server/subscription","commits_url":"https://api.github.com/repos/Graylog2/graylog2-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Graylog2/graylog2-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Graylog2/graylog2-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Graylog2/graylog2-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Graylog2/graylog2-server/contents/{+path}","compare_url":"https://api.github.com/repos/Graylog2/graylog2-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Graylog2/graylog2-server/merges","archive_url":"https://api.github.com/repos/Graylog2/graylog2-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Graylog2/graylog2-server/downloads","issues_url":"https://api.github.com/repos/Graylog2/graylog2-server/issues{/number}","pulls_url":"https://api.github.com/repos/Graylog2/graylog2-server/pulls{/number}","milestones_url":"https://api.github.com/repos/Graylog2/graylog2-server/milestones{/number}","notifications_url":"https://api.github.com/repos/Graylog2/graylog2-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Graylog2/graylog2-server/labels{/name}","releases_url":"https://api.github.com/repos/Graylog2/graylog2-server/releases{/id}","deployments_url":"https://api.github.com/repos/Graylog2/graylog2-server/deployments","created_at":"2010-05-17T21:27:02Z","updated_at":"2016-12-16T15:37:14Z","pushed_at":"2016-12-16T16:28:52Z","git_url":"git://github.com/Graylog2/graylog2-server.git","ssh_url":"git@github.com:Graylog2/graylog2-server.git","clone_url":"https://github.com/Graylog2/graylog2-server.git","svn_url":"https://github.com/Graylog2/graylog2-server","homepage":"https://www.graylog.org/","size":55187,"stargazers_count":2558,"watchers_count":2558,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":372,"mirror_url":null,"open_issues_count":371,"forks":372,"open_issues":371,"watchers":2558,"default_branch":"master"}},"base":{"label":"Graylog2:master","ref":"master","sha":"3fa1ea5bc1ca54852e7580ebfdc46d0c3547e431","user":{"login":"Graylog2","id":474892,"avatar_url":"https://avatars.githubusercontent.com/u/474892?v=3","gravatar_id":"","url":"https://api.github.com/users/Graylog2","html_url":"https://github.com/Graylog2","followers_url":"https://api.github.com/users/Graylog2/followers","following_url":"https://api.github.com/users/Graylog2/following{/other_user}","gists_url":"https://api.github.com/users/Graylog2/gists{/gist_id}","starred_url":"https://api.github.com/users/Graylog2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Graylog2/subscriptions","organizations_url":"https://api.github.com/users/Graylog2/orgs","repos_url":"https://api.github.com/users/Graylog2/repos","events_url":"https://api.github.com/users/Graylog2/events{/privacy}","received_events_url":"https://api.github.com/users/Graylog2/received_events","type":"Organization","site_admin":false},"repo":{"id":671825,"name":"graylog2-server","full_name":"Graylog2/graylog2-server","owner":{"login":"Graylog2","id":474892,"avatar_url":"https://avatars.githubusercontent.com/u/474892?v=3","gravatar_id":"","url":"https://api.github.com/users/Graylog2","html_url":"https://github.com/Graylog2","followers_url":"https://api.github.com/users/Graylog2/followers","following_url":"https://api.github.com/users/Graylog2/following{/other_user}","gists_url":"https://api.github.com/users/Graylog2/gists{/gist_id}","starred_url":"https://api.github.com/users/Graylog2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Graylog2/subscriptions","organizations_url":"https://api.github.com/users/Graylog2/orgs","repos_url":"https://api.github.com/users/Graylog2/repos","events_url":"https://api.github.com/users/Graylog2/events{/privacy}","received_events_url":"https://api.github.com/users/Graylog2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Graylog2/graylog2-server","description":"Free and open source log management","fork":false,"url":"https://api.github.com/repos/Graylog2/graylog2-server","forks_url":"https://api.github.com/repos/Graylog2/graylog2-server/forks","keys_url":"https://api.github.com/repos/Graylog2/graylog2-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Graylog2/graylog2-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Graylog2/graylog2-server/teams","hooks_url":"https://api.github.com/repos/Graylog2/graylog2-server/hooks","issue_events_url":"https://api.github.com/repos/Graylog2/graylog2-server/issues/events{/number}","events_url":"https://api.github.com/repos/Graylog2/graylog2-server/events","assignees_url":"https://api.github.com/repos/Graylog2/graylog2-server/assignees{/user}","branches_url":"https://api.github.com/repos/Graylog2/graylog2-server/branches{/branch}","tags_url":"https://api.github.com/repos/Graylog2/graylog2-server/tags","blobs_url":"https://api.github.com/repos/Graylog2/graylog2-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Graylog2/graylog2-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Graylog2/graylog2-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Graylog2/graylog2-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Graylog2/graylog2-server/statuses/{sha}","languages_url":"https://api.github.com/repos/Graylog2/graylog2-server/languages","stargazers_url":"https://api.github.com/repos/Graylog2/graylog2-server/stargazers","contributors_url":"https://api.github.com/repos/Graylog2/graylog2-server/contributors","subscribers_url":"https://api.github.com/repos/Graylog2/graylog2-server/subscribers","subscription_url":"https://api.github.com/repos/Graylog2/graylog2-server/subscription","commits_url":"https://api.github.com/repos/Graylog2/graylog2-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Graylog2/graylog2-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Graylog2/graylog2-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Graylog2/graylog2-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Graylog2/graylog2-server/contents/{+path}","compare_url":"https://api.github.com/repos/Graylog2/graylog2-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Graylog2/graylog2-server/merges","archive_url":"https://api.github.com/repos/Graylog2/graylog2-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Graylog2/graylog2-server/downloads","issues_url":"https://api.github.com/repos/Graylog2/graylog2-server/issues{/number}","pulls_url":"https://api.github.com/repos/Graylog2/graylog2-server/pulls{/number}","milestones_url":"https://api.github.com/repos/Graylog2/graylog2-server/milestones{/number}","notifications_url":"https://api.github.com/repos/Graylog2/graylog2-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Graylog2/graylog2-server/labels{/name}","releases_url":"https://api.github.com/repos/Graylog2/graylog2-server/releases{/id}","deployments_url":"https://api.github.com/repos/Graylog2/graylog2-server/deployments","created_at":"2010-05-17T21:27:02Z","updated_at":"2016-12-16T15:37:14Z","pushed_at":"2016-12-16T16:28:52Z","git_url":"git://github.com/Graylog2/graylog2-server.git","ssh_url":"git@github.com:Graylog2/graylog2-server.git","clone_url":"https://github.com/Graylog2/graylog2-server.git","svn_url":"https://github.com/Graylog2/graylog2-server","homepage":"https://www.graylog.org/","size":55187,"stargazers_count":2558,"watchers_count":2558,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":372,"mirror_url":null,"open_issues_count":371,"forks":372,"open_issues":371,"watchers":2558,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Graylog2/graylog2-server/pulls/3209"},"html":{"href":"https://github.com/Graylog2/graylog2-server/pull/3209"},"issue":{"href":"https://api.github.com/repos/Graylog2/graylog2-server/issues/3209"},"comments":{"href":"https://api.github.com/repos/Graylog2/graylog2-server/issues/3209/comments"},"review_comments":{"href":"https://api.github.com/repos/Graylog2/graylog2-server/pulls/3209/comments"},"review_comment":{"href":"https://api.github.com/repos/Graylog2/graylog2-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Graylog2/graylog2-server/pulls/3209/commits"},"statuses":{"href":"https://api.github.com/repos/Graylog2/graylog2-server/statuses/e0c4c987a5f915b990300f8742c0ee09f125d6d4"}}}}
{"actor":{"display_login":"joschi"}}