{"action":"created","issue":{"url":"https://api.github.com/repos/couchbase/cbgt/issues/7","labels_url":"https://api.github.com/repos/couchbase/cbgt/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/couchbase/cbgt/issues/7/comments","events_url":"https://api.github.com/repos/couchbase/cbgt/issues/7/events","html_url":"https://github.com/couchbase/cbgt/issues/7","id":122840659,"number":7,"title":"Panic when PIndexImplType New function returns nil","user":{"login":"tleyden","id":296876,"avatar_url":"https://avatars.githubusercontent.com/u/296876?v=3","gravatar_id":"","url":"https://api.github.com/users/tleyden","html_url":"https://github.com/tleyden","followers_url":"https://api.github.com/users/tleyden/followers","following_url":"https://api.github.com/users/tleyden/following{/other_user}","gists_url":"https://api.github.com/users/tleyden/gists{/gist_id}","starred_url":"https://api.github.com/users/tleyden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tleyden/subscriptions","organizations_url":"https://api.github.com/users/tleyden/orgs","repos_url":"https://api.github.com/users/tleyden/repos","events_url":"https://api.github.com/users/tleyden/events{/privacy}","received_events_url":"https://api.github.com/users/tleyden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-17T22:53:27Z","updated_at":"2015-12-17T23:19:14Z","closed_at":null,"body":"I think that the `RegisterPIndexImplType.New` function that is passed to CBGT:\r\n\r\n```\r\ncbgt.RegisterPIndexImplType(base.IndexTypeSyncGateway, &cbgt.PIndexImplType{\r\n\t\tNew: <--\r\n```\r\n\r\nis returning `nil`, and it's causing CBGT to panic.  I think in general, libraries shouldn't panic .. I guess maybe we could provide an `OnError` callback function or something instead?\r\n\r\n```\r\n015-12-17T14:48:25.672-08:00 WARNING: Could not find database for bucket name: bucket-1.  Unable to instantiate this pindex from disk. -- rest.(*ServerContext).SyncGatewayPIndexFactoryCommon() at server_context.go:185\r\n2015/12/17 14:48:25 manager: loading dataDir... done\r\n2015/12/17 14:48:25 planner: awakes, reason: start\r\n2015/12/17 14:48:25 janitor: awakes, reason: start\r\n2015/12/17 14:48:25 janitor: pindexes to remove: 0\r\n2015/12/17 14:48:25 janitor: pindexes to add: 0\r\n2015/12/17 14:48:25 janitor: feeds to remove: 0\r\n2015/12/17 14:48:25 janitor: feeds to add: 1\r\n2015/12/17 14:48:25   bucket-17732d5ba13e3a6f221f7d00f3e8c6234_2ff2a92097a52ba3\r\n2015/12/17 14:48:25 feed_dcp: start, name: bucket-17732d5ba13e3a6f221f7d00f3e8c6234_2ff2a92097a52ba3\r\npanic: runtime error: invalid memory address or nil pointer dereference\r\n[signal 0xb code=0x1 addr=0x48 pc=0x41bdb3e]\r\n\r\ngoroutine 81 [running]:\r\ngithub.com/couchbase/cbgt.(*DCPFeed).GetMetaData.func1(0x0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/cbgt/feed_dcp.go:477 +0x12e\r\ngithub.com/couchbase/cbgt.Timer.func1()\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/cbgt/misc.go:234 +0x25\r\ngithub.com/rcrowley/go-metrics.(*StandardTimer).Time(0xc8206224e0, 0xc8203ea960)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/rcrowley/go-metrics/timer.go:212 +0x3d\r\ngithub.com/couchbase/cbgt.Timer(0xc8204083f0, 0x5640b28, 0xc8206224e0, 0x0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/cbgt/misc.go:235 +0xa7\r\ngithub.com/couchbase/cbgt.(*DCPFeed).GetMetaData(0xc820604c30, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/cbgt/feed_dcp.go:480 +0x123\r\ngithub.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).getVBucketMetaData(0xc820375680, 0x20, 0x60, 0x486e340, 0x0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:1235 +0xa2\r\ngithub.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).sendStreamReq(0xc820375680, 0xc8203b0ae0, 0x20, 0x0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:1275 +0x53\r\ngithub.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).refreshWorker(0xc820375680, 0xc8203b0ae0, 0xc820408180, 0xc8200b8400, 0x40, 0x40, 0x0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:1011 +0x84e\r\ngithub.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).worker(0xc820375680, 0xc8203ce6c0, 0xf, 0xc82014f860, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:957 +0x11ea\r\ngithub.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).workerStart.func1.1(0x2)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:681 +0x48\r\ngithub.com/couchbase/go-couchbase/cbdatasource.ExponentialBackoffLoop(0xc820150e10, 0x23, 0xc820289f38, 0x64, 0x3fc00000, 0x4e20)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:1518 +0x2b\r\ngithub.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).workerStart.func1(0xc820375680, 0xc8203ce6c0, 0xf, 0xc82014f860, 0x64, 0xc83fc00000, 0x4e20)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:682 +0x112\r\ncreated by github.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).workerStart\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:685 +0xb7\r\n```\r\n\r\nNoticed this during some experimentation trying to fix https://github.com/couchbase/sync_gateway/issues/1299"},"comment":{"url":"https://api.github.com/repos/couchbase/cbgt/issues/comments/165612850","html_url":"https://github.com/couchbase/cbgt/issues/7#issuecomment-165612850","issue_url":"https://api.github.com/repos/couchbase/cbgt/issues/7","id":165612850,"user":{"login":"tleyden","id":296876,"avatar_url":"https://avatars.githubusercontent.com/u/296876?v=3","gravatar_id":"","url":"https://api.github.com/users/tleyden","html_url":"https://github.com/tleyden","followers_url":"https://api.github.com/users/tleyden/followers","following_url":"https://api.github.com/users/tleyden/following{/other_user}","gists_url":"https://api.github.com/users/tleyden/gists{/gist_id}","starred_url":"https://api.github.com/users/tleyden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tleyden/subscriptions","organizations_url":"https://api.github.com/users/tleyden/orgs","repos_url":"https://api.github.com/users/tleyden/repos","events_url":"https://api.github.com/users/tleyden/events{/privacy}","received_events_url":"https://api.github.com/users/tleyden/received_events","type":"User","site_admin":false},"created_at":"2015-12-17T23:19:14Z","updated_at":"2015-12-17T23:19:14Z","body":"Reproduced on commit 17117fba8c0d31a3ad841539b067b5cd5e33fcac\r\n\r\n```\r\npanic: runtime error: invalid memory address or nil pointer dereference\r\n[signal 0xb code=0x1 addr=0x48 pc=0x41be42e]\r\n\r\ngoroutine 123 [running]:\r\ngithub.com/couchbase/cbgt.(*DCPFeed).GetMetaData.func1(0x0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/cbgt/feed_dcp.go:477 +0x12e\r\ngithub.com/couchbase/cbgt.Timer.func1()\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/cbgt/misc.go:234 +0x25\r\ngithub.com/rcrowley/go-metrics.(*StandardTimer).Time(0xc8205bc7b0, 0xc820440e60)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/rcrowley/go-metrics/timer.go:212 +0x3d\r\ngithub.com/couchbase/cbgt.Timer(0xc820518f00, 0x52a97a8, 0xc8205bc7b0, 0x0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/cbgt/misc.go:235 +0xa7\r\ngithub.com/couchbase/cbgt.(*DCPFeed).GetMetaData(0xc820074270, 0x2d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/cbgt/feed_dcp.go:480 +0x123\r\ngithub.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).getVBucketMetaData(0xc820620900, 0x2d, 0x60, 0x4878dc0, 0x0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:1235 +0xa2\r\ngithub.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).sendStreamReq(0xc820620900, 0xc8203647e0, 0x2d, 0x0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:1275 +0x53\r\ngithub.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).refreshWorker(0xc820620900, 0xc8203647e0, 0xc820518d80, 0xc8200a6580, 0x40, 0x40, 0x0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:1011 +0x84e\r\ngithub.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).worker(0xc820620900, 0xc820414ba0, 0xf, 0xc82016d1a0, 0x0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:957 +0x11ea\r\ngithub.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).workerStart.func1.1(0x2)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:681 +0x48\r\ngithub.com/couchbase/go-couchbase/cbdatasource.ExponentialBackoffLoop(0xc8205bd2c0, 0x23, 0xc820591f38, 0x64, 0x3fc00000, 0x7d0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:1518 +0x2b\r\ngithub.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).workerStart.func1(0xc820620900, 0xc820414ba0, 0xf, 0xc82016d1a0, 0x64, 0xc83fc00000, 0x7d0)\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:682 +0x112\r\ncreated by github.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).workerStart\r\n\t/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:685 +0xb7\r\n```"}}