What is heartbeat replication monitoring? [closed] - mysql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
What is the meaning of "master heartbeat time period" in MySQL server, and how can I configure this variable in my.cnf?

As mentioned here on the mysql performance blog
MASTER_HEATBEAT_PERIOD is a value in seconds in the range between 0 to 4294967 with resolution in milliseconds. After the loss of a beat the SLAVE IO Thread will disconnect and try to connect again.
You can configure it on a slave using syntax also mentioned in that article and in the queries below.
mysql_slave > STOP SLAVE;
mysql_slave > CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD=1;
mysql_slave > START SLAVE;
More information on using CHANGE MASTER can be found on the mysql documentation site
MASTER_HEARTBEAT_PERIOD sets the interval in seconds between replication heartbeats. Whenever the master's binary log is updated with an event, the waiting period for the next heartbeat is reset. interval is a decimal value having the range 0 to 4294967 seconds and a resolution in milliseconds; the smallest nonzero value is 0.001. Heartbeats are sent by the master only if there are no unsent events in the binary log file for a period longer than interval.
Setting interval to 0 disables heartbeats altogether. The default value for interval is equal to the value of slave_net_timeout divided by 2.

Related

How to adjust parameters for mysql connection failure [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 11 hours ago.
Improve this question
I'm using Azure database for mysql, there is a problem with a "Failed Connections".
Currently, connections are crowded at a specific time, and a specific select query is confirmed by more than half of the slow query logs.
Among several parameters, the values of parameters related to connection are as follows.
connect_timeout : 10 (units are seconds)
wait_timeout : 360
interactive_timeout : 28800
long_query_time : 5
net_read_timeout : 120
net_write_timeout : 240
slave_net_timeout : 60
and I heard that I need to create a "replication database" for slow queries, but I wonder if there is any other solutions by adjusting the mysql parameters.

how to release a lock automatically in mysql

My question is similar to this questionMySQL rollback on transaction with lost/disconnected connection ,but it was 5 years ago.
If a client(like jdbc or something else) lock one row in table, execute some statements then network is down, so mysql would never receive commit or rollback command from client, does mysql support to rollback this transaction(unlock row) automatically?
I refer innodb_rollback_on_timeout it says If --innodb_rollback_on_timeout is specified, a transaction timeout causes InnoDB to abort and roll back the entire transaction, but how long is the transaction timeout and where to set it?
The accepted answer in similar question is to use wait_timeout, if wait_timeout is set to a small number like 10 seconds, so the idle connections in pool(if used) need to test connection every 10 seconds before they are disconnected by mysql sever, is the cost too high? or is there other ways(configuration will be best) to solve my question?
Actually there's no settings for transaction timeout, still wait_timeout or interactive_timeout applies. What --innodb_rollback_on_timeout affected is the behavior of rollback(whole transaction or statements in the transation).

how to implement implicit row level locking in innodb? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm using MySql(innodb storage engine). I want to implement row level implicit locking on update statement. so, that no other transaction can read or update that row concurrently.
Example:
Transaction1 is executing
"UPDATE Customers
SET City='Hamburg'
WHERE CustomerID=1;"
Then, at same time Transaction2 should not able to read or update same row but Transaction2 should be able to access other rows.
Any help would be appreciated.
Thank you for your time.
If there are no other statements supporting that UPDATE, it is atomic.
If, for example, you needed to look at the row before deciding to change it, then it is a little more complex:
BEGIN;
SELECT ... FOR UPDATE;
decide what you need to do
UPDATE ...;
COMMIT;
No other connection can change with the row(s) SELECTed before the COMMIT.
Other connections can see the rows involved, but they may be seeing the values before the BEGIN started. Reads usually don't matter. What usually matters is that everything between BEGIN and COMMIT is "consistent", regardless of what is happening in other connections.
Your connection might be delayed, waiting for another connection to let go of something (such as the SELECT...FOR UPDATE). Some other connection might be delayed. Or there could be a "deadlock" -- when InnoDB decides that waiting will not work.

How to periodically update status in MySQL [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
The community reviewed whether to reopen this question 8 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I'm creating a todo app. I have a status column that receives 1, 2 or 3 (pending, overdue, completed).
Whenever I create a task it is set to pending. The user can mark it as complete. But is there a way to automatically update it to overdue in case it's not completed and due_date is less than today?
You can use MySQL event Scheduler.
Prerequisite:
You have to have event_scheduler ON in your mysql server.
Check whether event scheduler is ON or OFF
SELECT ##event_scheduler;
To turn event_scheduler ON run the following query:
SET GLOBAL event_scheduler = ON;
Note: If you restart MYSQL Server then event scheduler status will be reset unless the following is written in the configuration file.
For Windows: in my.ini file write this under [mysqld] section
[mysqld]
event_scheduler=on
For Linux: in my.cnf file
[mysqld]
event_scheduler=on
Event:
CREATE
EVENT `updateStatusEvent`
ON SCHEDULE EVERY 1 DAY STARTS '2016-08-11 00:00:00'
ON COMPLETION NOT PRESERVE
ENABLE
DO
UPDATE your_table SET status_column = 2 WHERE your_time_column < CURDATE();
The event will be started for the first time at '2016-08-11 00:00:00'
and after that the event will be scheduled in every 1 day interval and will update the status of the corresponding data.
If your version of MySQL supports it (version >= 5.1.6 if I'm not mistaken) you can use Event Scheduler.
CREATE EVENT check_overdue ON SCHEDULE EVERY 2 HOUR DO
UPDATE mytable SET status = 2 WHERE due_date < NOW();
Another option is to set up a Cron job that calls a PHP or another online script.
Anyway you have to query periodically for any overdue events and mark them as overdue.

How does mysql replication work? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
From what I've been able to find in the web, mysql stores statements that alter data in the bin log, which is then read by the slave. What remains unclear is what happens to those statements next? Are they replayed as if they happenned on the slave server?
For example, say there is a query with current time in the conditional, like "UPDATE something SET updatedat = NOW()", and due to the replication delay, the query ends at the slave a couple of seconds later. Will the values in the table be different?
Or if there is master-master replication, at time 1000 the following query happens on server 1:
UPDATE t SET data = 'old', updatedat = 1000 WHERE updatedat < 1000
At time 1001 on server 2 the following query happens:
UPDATE t SET data = 'new', updatedat = 1001 WHERE updatedat < 1001
Then server 2 fetches the replication log from server 1, the value on the server 2 will be "old"? If so, is there a way to avoid it?
For example, say there is a query with current time in the conditional, like "UPDATE something SET updatedat = NOW()", and due to the replication delay, the query ends at the slave a couple of seconds later. Will the values in the table be different?
No. The replication duplicates the row, which means that the time will be the same