Redshift でユーザーの接続制限数以上のコネクションを張ろうとすると即時エラーになる。
検証結果
- 3本接続を張った後、4本目の接続を張ろうとすると即時エラーとなる。
$ psql -A -h rs-ra3-4xl-4n.********.us-east-1.redshift.amazonaws.com -p 5439 -d dev -U testuser Password for user testuser: psql: error: connection to server at "rs-ra3-4xl-4n.********.us-east-1.redshift.amazonaws.com" (10.0.13.174), port 5439 failed: FATAL: too many connections for user "testuser"
事前準備
- Redshift に接続する。
$ psql -A -h rs-ra3-4xl-4n.********.us-east-1.redshift.amazonaws.com -p 5439 -d dev -U awsuser
- ユーザーを作成する。
CREATE USER testuser password 'abcD1234' CONNECTION LIMIT 3;
参考
構文
CREATE USER name [ WITH ] PASSWORD { 'password' | 'md5hash' | 'sha256hash' | DISABLE } [ option [ ... ] ] where option can be: CREATEDB | NOCREATEDB | CREATEUSER | NOCREATEUSER | SYSLOG ACCESS { RESTRICTED | UNRESTRICTED } | IN GROUP groupname [, ... ] | VALID UNTIL 'abstime' | CONNECTION LIMIT { limit | UNLIMITED } | SESSION TIMEOUT limit | EXTERNALID external_id(中略)
https://docs.aws.amazon.com/ja_jp/redshift/latest/dg/r_CREATE_USER.html:tilteCONNECTION LIMIT { limit | UNLIMITED }
ユーザーが同時に開けるデータベース接続の最大数。この制限はスーパーユーザーには適用されません。同時接続の最大数を許可するには、UNLIMITED キーワードを使用します。データベースごとの接続数の制限が適用される場合もあります。詳細については、「CREATE DATABASE」を参照してください。デフォルトは UNLIMITED です。現在の接続を確認するには、STV_SESSIONSシステムビューに対してクエリを実行します。