Sync gateway 2.1 throwing "Panic: runtime error: index out of range" error

Sync gateway 2.1 is throwing the following error:

SELECT meta(ex_test).xattrs._sync.access.EX_502798616 as value FROM ex_test WHERE any op in object_pairs(meta(ex_test).xattrs._sync.access) satisfies op.name = ‘EX_502798616’ end;

[WRN] QueryAccess returned error: [5001] Panic: runtime error: index out of range -- db.(*DatabaseContext).ComputeSequenceChannelsForPrincipal() at crud.go:1367[0m
[WRN] channelComputer.ComputeChannelsForPrincipal returned error for &{roleImpl:{Name_:EX_502798616 ExplicitChannels_: Channels_: Sequence_:22023 PreviousChannels_: vbNo:<nil>} userImplBody:{Email_: Disa
bled_:false PasswordHash_:[36 50 97 36 49 48 36 67 73 51 68 71 97 122 109 71 114 106 115 75 78 89 89 102 55 54 117 88 46 54 46 65 105 47 87 76 55 66 65 110 97 46 73 66 50 82 66 53 98 86 86 119 52 49 105 119 82 103 49 101] OldPasswordHash
_:<nil> ExplicitRoles_: RolesSince_:fluidsEngineer:20866 OldExplicitRoles_:[]} auth:<nil> roles:[]}: [5001] Panic: runtime error: index out of range -- auth.(*Authenticator).rebuildChannels() at auth.go:172[0m
[WRN] RebuildChannels returned error: [5001] Panic: runtime error: index out of range -- auth.(*Authenticator).getPrincipal.func1() at auth.go:121[0m
[INF] HTTP: #180780:     --> 500 Internal error: [5001] Panic: runtime error: index out of range  (36.9 ms)[0m`Preformatted text`

Please help to understand what’s going on …

Hi @dony.thomas,

What version of Couchbase Server are you running? And are you on Sync Gateway 2.1.0 or another 2.1 version?

We’re using Couchbase Enterprise Edition 6.0.0 build 1693 & Couchbase Sync Gateway 2.1

I think you might be hitting the bug mentioned here: https://issues.couchbase.com/browse/MB-32120

This was fixed in Couchbase Server 6.0.1, but we had some important fixes in 6.0.2 as well which you might be interested in upgrading to: https://docs.couchbase.com/server/6.0/release-notes/relnotes.html