'another command is already in progress' returned when trying to rebalance shards - postgresql

There are two Postgres instances running in a Citus cluster:
analysis=# select * from citus_check_cluster_node_health();
from_nodename | from_nodeport | to_nodename | to_nodeport | result
---------------+---------------+-------------+-------------+--------
myhost | 5400 | myhost | 5400 | t
myhost | 5400 | myhost | 5432 | t
myhost | 5432 | myhost | 5400 | t
myhost | 5432 | myhost | 5432 | t
(4 rows)
When trying to rebalance shards in a table:
SELECT * FROM rebalance_table_shards('mydist1');
There is returned an error:
NOTICE: Moving shard 102008 from myhost:5432 to myhost:5400 ...
ERROR: connection to the remote node myhost:5400 failed with the following error: another command is already in progress
CONTEXT: while executing command on localhost:5432
What is the reason of this error?

Related

Issue in postgresql HA mode switching of Master node

I am new in postgresqlDB configuration. I am trying to configure postgresDB in HA mode with the help of pgpool and Elastic IP. Full setup is in AWS RHEL 8 servers.
pgpool version : 4.1.2
postgres version - 12
Below links I have followed during the configuration:
https://www.pgpool.net/docs/pgpool-II-4.1.2/en/html/example-cluster.html#EXAMPLE-CLUSTER-STRUCTURE
https://www.pgpool.net/docs/42/en/html/example-aws.html
https://www.enterprisedb.com/docs/pgpool/latest/03_configuring_connection_pooling/
Currently the postgres and pgpool services are up in all 3 component nodes. But if I am stopping master postgres service/server whole setup is going down and standby node is not taking the place of master. Please find the status of the pool nodes when master is down:
node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
---------+--------------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
0 | server1 | 5432 | down | 0.333333 | standby | 0 | false | 0 | | | 2022-10-12 12:10:13
1 | server2 | 5432 | up | 0.333333 | standby | 0 | true | 0 | | | 2022-10-13 09:16:07
2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | | | 2022-10-13 09:16:07
Any help would be appreciated. Thanks in advance.

Unable to create new database

When I create a new mysql db, slashdb's test connection fails.
Here is how I log into mysql:
$ mysql -u 7stud -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.5.5-10.4.13-MariaDB Homebrew
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| chat |
| ectoing_repo |
| ejabberd |
| information_schema |
| mydb |
| mysql |
| performance_schema |
| test |
+--------------------+
8 rows in set (0.00 sec)
mysql> use mydb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------+
| Tables_in_mydb |
+----------------+
| cheetos |
| greetings |
| mody |
| people |
+----------------+
4 rows in set (0.00 sec)
mysql> select * from people;
+----+--------+------+
| id | name | info |
+----+--------+------+
| 1 | 7stud | abc |
| 2 | Beth | xxx |
| 3 | Diane | xyz |
| 4 | Kathy | xyz |
| 5 | Kathy | xyz |
| 6 | Dave | efg |
| 7 | Tom | zzz |
| 8 | David | abc |
| 9 | Eloise | abc |
| 10 | Jess | xyz |
| 11 | Jeffsy | 2.0 |
| 12 | XXX | xxx |
| 13 | XXX | xxx |
+----+--------+------+
13 rows in set (0.00 sec)
In the slashdb form for creating a new database, here is the info I entered:
Hostname: 127.0.0.1
Port: 80
Database Login: 7stud
Database Password: **
Database Name: mydb
Then I hit the "Test Connection" button, whereupon I get a spinning wheel, which disappears after a few minutes, but no "Connection Successful" message. What am I doing wrong?
Now, I'm using port 3306:
mysql> SHOW GLOBAL VARIABLES LIKE 'PORT';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set (0.00 sec)
but when slashdb tries to connect, I get the error:
Host localhost:3306 is not accessible
Your port is wrong in the database connection. You said that your MySQL is configured on port 3306, but you also posted your SlashDB config for database with port 80. Please change that to 3306.
Also, not sure how if you don't need to enable remote access to MySQL. Even if your SlashDB is running on the same machine as the MySQL database, it uses TCP/IP to connect.

pgpool-II 3.7.5 not caching PG connections

Shouldn't pgpool cache PG backend processes? After disconnecting and reconnecting pool_backendpidchanges.
Relevant parameters:
num_init_children = 1
max_pool = 1
child_life_time = 300
child_max_connections = 0
connection_life_time = 0
client_idle_limit = 0
connection_cache = on
Test:
postgres#node3:/etc/pgpool2$ psql -p 5433 -U postgres postgres
psql (9.6.10)
Type "help" for help.
postgres=# show pool_pools;
LOG: statement: show pool_pools;
pool_pid | start_time | pool_id | backend_id | database | username | create_time | majorversion | minorversion | pool_counter | pool_backendpid | pool_connected
----------+---------------------+---------+------------+----------+----------+---------------------+--------------+--------------+--------------+-----------------+----------------
3569 | 2018-09-13 20:18:22 | 0 | 0 | postgres | postgres | 2018-09-13 20:25:04 | 3 | 0 | 1 | 3631 | 1
(1 row)
postgres=# \q
postgres#node3:/etc/pgpool2$ psql -p 5433 -U postgres postgres
psql (9.6.10)
Type "help" for help.
postgres=# show pool_pools;
LOG: statement: show pool_pools;
pool_pid | start_time | pool_id | backend_id | database | username | create_time | majorversion | minorversion | pool_counter | pool_backendpid | pool_connected
----------+---------------------+---------+------------+----------+----------+---------------------+--------------+--------------+--------------+-----------------+----------------
3569 | 2018-09-13 20:18:22 | 0 | 0 | postgres | postgres | 2018-09-13 20:25:15 | 3 | 0 | 1 | 3640 | 1
(1 row)
Found out why:
connection_cache (boolean)
Caches connections to backends when set to on. Default is on. However,
connections to template0, template1, postgres and regression databases
are not cached even if connection_cache is on.
I was connecting to postgres database.

Datadog: PostgreSQL custom_metrics returns a single row

I wanted to create a graph in Datadog to display iddle connections per user.
Following this example: http://www.miketheman.net/tag/postgres/ I changed my postgres.yaml configuration to:
init_config:
instances:
- host: 127.0.0.1
port: 5432
username: datadog
password: '**************'
tags:
- environment:qa
- role:db
custom_metrics:
- # Postgres Connection state
descriptors:
- [datname, database]
- [usename, user]
- [state, state]
metrics:
COUNT(state): [postgresql.connection_state, GAUGE]
query: >
SELECT datname, usename, state, %s FROM pg_stat_activity
GROUP BY datname, usename, state HAVING COUNT(state) > 0;
relation: false
I can see the metric is appearing in Datadog, but I can just see one of the rows that should appear (has I have several databases in my PostgreSQL).
Here is the datadog connection graph
Am I missing any step? Is postgres.yaml missing any configuration?
Running that query in psql, I get this (modifying names but not data):
postgres=# SELECT datname, usename, state, COUNT(state) FROM pg_stat_activity GROUP BY datname, usename, state HAVING COUNT(state) > 0;
datname | usename | state | count
---------------------+-------------+---------------------+-------
compan_strawberr_qa | compan | idle in transaction | 1
compan_qa | compan | idle | 130
pineappplee_qa | compan | idle | 10
compan_strawberr_qa | compan | idle | 29
compan_qa | watermel | active | 1
pineappplee_qa | pineappplee | idle | 10
pear_qa | pear | idle | 6
postgres | postgres | active | 1
postgres | datadog | idle | 1
apple_qa | apple_qa | idle | 1
bblluebberrriiess | compan | idle | 3
compan_ser_qa | ser_qa | idle | 4
compan_service_qa | compan | idle | 26
(13 rows)
I found the solution: the user datadog didnt have permission to read connections that wasnt form him. So it was just getting a single row.
I gave permissions for that user to read pg_stat_activity

MongoDB Authentication failed in robotframework

I tried to connect and authenticate mongodb through robotframework.
followed the following steps:
Connect To MondoDB | mongodb://admin:admin#192.20.33.226 | 27017 | 10 | None | <type 'dict'> | False |
Sucessfully connected.
Tried to query from database
Retrieve Mongodb Records With Desired Fields dbName | dbCollName | recordJSON | fields | return__id=True | returnDocuments=False
after execution of this statement, i got the following error.
OperationFailure: Authentication failed.
log:
Starting test: MongoConnection.Query from MongoDB
20161209 17:05:05.866 : INFO :
| Connect To MondoDB | dbHost | dbPort | dbMaxPoolSize | dbNetworktimeout | dbDocClass | dbTZAware |
| Connect To MondoDB | mongodb://tecnotree:tecnotree#172.20.33.226 | 27017 | 10 | None | <type 'dict'> | False |
20161209 17:05:05.907 : INFO : | ${allResults} | retreive_mongodb_records_with_desired_fields | clmpreprod | Profile | { "profileDetails.basicDetails.customerCode": "C014519" } | profileDetails.customerCategory.masterCode,profileDetails.customerSubCategory.masterCode | False |
20161209 17:05:05.910 : FAIL : OperationFailure: Authentication failed.
Ending test: MongoConnection.Query from MongoDB
I sat with my MongoDB database analysit and debugged, we comes to know that, first it tried to connect to adminDB with the user credentials given and at the time of query it connected to actual db.
here, in our system credentials for admin db and system db are different, that's why it failed.
our db analyst confirmed that , they will not allow to connect to admin db as it will have all permissions.
can any one help me , how to connect and query from mongodb which will not connect to admin db.
Thanks
Sarada
Most of the drivers support the same style of connection string, so you should be able to append the following query things to your current connection string:
mongodb://username:password#host/database?authSource=authDatabase
See
https://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html#auth-options
or
http://api.mongodb.com/python/current/examples/authentication.html?highlight=url#delegated-authentication
you should mention dbname also at the time connecting
Connect To MondoDB | mongodb://admin:admin#192.20.33.216/userDB | 27017 | 10 | None | <type 'dict'> | False
Retrieve Mongodb Records With Desired Fields dbName | dbCollName | recordJSON | fields | return__id=True | returnDocuments=False
This will work
Thanks Kevin for your help