1. In a Yii 2.0 console command, the following error occurred: yii\db\Exception: Redis error: ERR invalid DB index
Redis command was: SELECT 29 in /vendor/yiisoft/yii2-redis/src/Connection.php:736. I checked /console/runtime/logs/app.log.
2019-08-09 09:44:13 [-][-][-][error][yii\db\Exception] yii\db\Exception: Redis error: ERR invalid DB index
Redis command was: SELECT 29 in /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php:736
Stack trace:
#0 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php(713): yii\redis\Connection->parseResponse('SELECT 29')
#1 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php(697): yii\redis\Connection->sendCommandInternal('*2\r\n$6\r\nSELECT\r...', Array)
#2 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php(559): yii\redis\Connection->executeCommand('SELECT', Array)
#3 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php(665): yii\redis\Connection->open()
#4 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php(630): yii\redis\Connection->executeCommand('SET', Array)
#5 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-queue/src/drivers/redis/Queue.php(135): yii\redis\Connection->__call('set', Array)
#6 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-queue/src/drivers/redis/Queue.php(59): yii\queue\redis\Queue->reserve(3)
#7 [internal function]: yii\queue\redis\Queue->yii\queue\redis\{closure}(Object(Closure))
#8 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-queue/src/cli/Queue.php(117): call_user_func(Object(Closure), Object(Closure))
#9 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-queue/src/drivers/redis/Queue.php(68): yii\queue\cli\Queue->runWorker(Object(Closure))
#10 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-queue/src/drivers/redis/Command.php(76): yii\queue\redis\Queue->run(true, 3)
#11 [internal function]: yii\queue\redis\Command->actionListen(3)
#12 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#13 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#14 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('listen', Array)
#15 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('listen', Array)
#16 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('upload-asset-qu...', Array)
#17 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('upload-asset-qu...', Array)
#18 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#19 /sobey/www/channel-pub-api/yii(23): yii\base\Application->run()
#20 {main}
2. Analysis revealed that the error occurred when executing the command: SELECT 29 to switch to database: 29. A Redis instance has 16 databases by default, ranging from 0 to 15. Exceeding this range triggers the ERR invalid DB index error, as shown in Figure 1.

#0 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php(713): yii\redis\Connection->parseResponse('SELECT 29')
3. I edited the redis.windows.conf and redis.windows-service.conf files, searched for: databases 16, and changed it to: databases 32.
# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT where
# dbid is a number between 0 and 'databases'-1
databases 32
4. In Windows 10, I stopped and started Redis.
PS C:\> redis-server --service-stop
[87292] 09 Aug 10:44:18.772 # Redis service successfully stopped.
PS C:\> redis-server --service-start
[77236] 09 Aug 10:44:31.673 # Redis service successfully started.
5. I opened RedisDesktopManager. The quantity changed to 20, but it could already execute the SELECT 0 – 31 commands, as shown in Figure 2.

6. I deleted the connection. In the new connection settings – Advanced Settings – Database Discovery Limit, the default value was 20, which I edited to 32, as shown in Figure 3.

7. I opened RedisDesktopManager. The quantity changed to 32, as expected, as shown in Figure 4.

