Modify mirroring_partner_instance name in sys.database_mirroring - c++

I have an issue with correctly failing over to the mirror database. When I am connected to the principal database (dbx) (mirroring is enabled and set up) and I fail over the principal database (shutting down SQL Server to simulate a crash), I can no longer send queries without a failure. This is expected since the previous connection is now lost.
I would like to simply close out my connections and handles and re-establish a new connection, using the same connection string, and re-connect to the mirror database (dby, which is now the principal database).
My connection string is as follows:
Driver={SQL Native Client};Server=dbx;Failover_Partner=dby;Database=db;Uid=uid;Pwd=pwd;Network=DBMSSOCN;
From doing research, I have learned that the Failover_Partner parameter in the connection is almost worthless. It is only used when the principal server is down and a new connection is being made for the first time. For some reason, the Failover_Partner is overwritten internally when a connection is established to the principal and the mirroring_partner_instance found in the sys.database_mirroring table is used instead. So when I specify the Failover_Partner to be dby, after I establish a connection, I query for what it thinks the failover partner is, and it returns the INSTANCE name of the failover partner and not the DNS name (dby).
Here is the issue, I cannot use the INSTANCE name as the failover partner. I am required to use the DNS name as the failover partner.
So my question(s) is/are this:
Is there a way to modify the sys.database_mirroring entry and change the mirroring_partner_instance?
Where does this field get its value from?
Is there any other way to force SQL Server to use the DNS name and NOT the INSTANCE name?

I found the answer to this question in case anyone has the same or a similar issue.
I had to modify the ##SERVERNAME property in SQL. It was internally set to the computer WIN-... instance name and I was able to drop it and add the server name I wanted with the following commands:
Get the current server name (WIN_NAME)
SELECT ##SERVERNAME
Drop the WIN-NAME
SP_DropServer 'WIN_NAME'
GO
SP_AddServer 'SERVER_NAME',local
GO
Restart SQL Server to see the changes take effect.

Related

Getting ec2 instance ID suddenly stopped working

I've been getting an amazon instance ID from within the instance itself for over a year now by hitting this local web address http://169.254.169.254/latest/meta-data/instance-id. This is the appropriate method according to the AWS documentation. For some reason though, just this week that same call started throwing an error.
I tried pinging the 169.254.169.254 address from the command line and that fails, so it seems like something pretty basic has changed with the EC2 instances. I don't see any changes to the documentation on AWS. One thing I do notice is that I used to see the instance name in the upper right hand corner when loading up the instance and logging in remotely. That information doesn't appear anymore.
Here is the code I've been using to get the ID:
retID = New StreamReader(HttpWebRequest.Create("http://169.254.169.254/latest/meta-data/instance-id").GetResponse().GetResponseStream()).ReadToEnd()
Here is the full error stack:
at System.Net.HttpWebRequest.GetResponse()
at RunControllerInterface.NewRunControlCommunicate.getInstanceIDFromAmazon()
The error message itself says: Unable to connect to the remote server
Any help would be appreciated.
So I think I have at least a partial answer to this problem. When making this image, I was using a t3a.medium instance. As long as I use that same type of instance I am able to pull down the instance name.

How to reconnect if AWS RDS recovery happens

How have I written the code
createPool is used at the start of the app
then for every request I am using getConnection
I am using AWS RDS & it went into sudden recovery mode, due to which my db url was unchanged but instance IP must have changed as it was created in another AZ
So for such a scenario I am supposed to reinitialize my db connection so that new instance DNS is updated.
The issue is in such a scenario I did not received any timeout error or connection error. So how do I capture this type of error?
Kindly guide if possible.
Thanks
It is unclear from your description what exactly you have built, but it sounds like you've created a connection pool.
If you open a connection to the db, the first time you call getConnection you should validate that the connection is still active - obviously if the db fails over, the existing connection will get closed, and you will either need to create a new connection or re-open the existing one.

mysql lost connection error

Currently, I am working on a project to integrate mysql with the IOCP server to collect sensor data and verify the collected data from the client.
However, there is a situation where mysql misses a connection.
The query itself is a simple query that inserts a single row of records or gets the average value between date intervals.
The data of each sensor flows into the DB at the same time every 5 seconds. When the messages of the sensors come on occasionally or overlap with the message of the client, the connection is disconnected.
lost connection to mysql server during query
In relation to throwing the above message
max_allowed_packet Numbers changed.
interactive_timeout, net_read_timeout, net_write_timeout, wait_timeout
It seems that if there are overlapping queries, an error occurs.
Please let me know if you know the solution.
I had a similar issue in a MySQL server with very simple queries where the number of concurrent queries were high. I had to disable the query cache to solve the issue. You could try disabling the query cache using following statements.
SET GLOBAL query_cache_size = 0;
SET GLOBAL query_cache_type = 0;
Please note that a server restart will enable the query cache again. Please put the configuration in MySQL configuration file if you need to have it preserved.
Can you run below command and check the current timeouts?
SHOW VARIABLES LIKE '%timeout';
You can change the timeout, if needed -
SET GLOBAL <timeout_variable>=<value>;

Use primary and secondary DNS servers in parellel for name resolutions

I am using the following API's for making a HTTP request.
QNetworkRequest Request (QUrl (QString (HTTP_PRF PING_URL)));
m_pNetworkReply = m_pNetAccesMgr->get (Request);
My resolv.conf has the following entries.
nameserver 8.8.8.8
nameserver 10.10.182.225
It seems that the QNetworkAccessManager's get API uses the nameservers sequentially to resolve the given domain name, i.e it tries 8.8.8.8 first, and if it fails it tries 10.10.182.255. Is there some way to make Qt to do this name resolution parallely.
I am no network expert, but it looks like a problem that would better be solved system wise than just by tweaking a single program.
According to Adjusting how long Linux takes to fail over to backup DNS server listed in resolv.conf, you can add this line to resolv.conf:
options timeout:1 attempts:1
This will set the timeout to 1s, switch dns server after first failed attempt.

buildforge problem

when i tried to run the job i am getting the error saying that
No server could be found matching all conditions
please any one help me on this
In buildforge, the job is assigned to a selector.
The selector can be thought of as a pointer to an object that can represent either the name of a server, or a set of servers that matches a set of criteria.
When the job executes, the selector for that step attempts to find the server based on the criteria defined in the selector conditions. If it can't find a server that matches the selection conditions, you get the posted error message.
In real life, this error usually indicates the following:
1. The agent on the server is dead, or the server is down. Run bfservertest (or test connection in the buildforge web UI) to see if the agent is functioning. Visit the machine remotely or in person to verify that the server is up. Try restarting the agent service if machine is up and connection test fails.
2. The selector is pointing to a non-existent server because you misspelled the server name.
3. You have conditions defined in the selector that unintentionally exclude all servers from being used.