1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

Revert "update the "uptime" command to indicate the "time since last" is the time since the last recovery OR failover."

This reverts commit 3b0d44497800a16400d05a30bdaf6e6c285d4b36.

(This used to be ctdb commit cb36bbb5418290e8e5b770d2d836285b15da2a6f)
This commit is contained in:
Ronnie Sahlberg 2009-10-29 10:49:00 +11:00
parent a4b8a17b26
commit 023d09cd38
6 changed files with 78 additions and 9 deletions

View File

@ -3141,12 +3141,42 @@ int ctdb_ctrl_getcapabilities(struct ctdb_context *ctdb, struct timeval timeout,
return ret;
}
/**
* check whether a transaction is active on a given db on a given node
*/
static int32_t ctdb_ctrl_transaction_active(struct ctdb_context *ctdb,
uint32_t destnode,
uint32_t db_id)
{
int32_t status;
int ret;
TDB_DATA indata;
indata.dptr = (uint8_t *)&db_id;
indata.dsize = sizeof(db_id);
ret = ctdb_control(ctdb, destnode, 0,
CTDB_CONTROL_TRANS2_ACTIVE,
0, indata, NULL, NULL, &status,
NULL, NULL);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " ctdb control for transaction_active failed\n"));
return -1;
}
return status;
}
struct ctdb_transaction_handle {
struct ctdb_db_context *ctdb_db;
bool in_replay;
/* we store the reads and writes done under a transaction one
list stores both reads and writes, the other just writes
*/
/*
* we store the reads and writes done under a transaction:
* - one list stores both reads and writes (m_all),
* - the other just writes (m_write)
*/
struct ctdb_marshall_buffer *m_all;
struct ctdb_marshall_buffer *m_write;
};
@ -3170,6 +3200,7 @@ static int ctdb_transaction_fetch_start(struct ctdb_transaction_handle *h)
int ret;
struct ctdb_db_context *ctdb_db = h->ctdb_db;
pid_t pid;
int32_t status;
key.dptr = discard_const(keyname);
key.dsize = strlen(keyname);
@ -3180,6 +3211,17 @@ static int ctdb_transaction_fetch_start(struct ctdb_transaction_handle *h)
}
again:
status = ctdb_ctrl_transaction_active(ctdb_db->ctdb,
CTDB_CURRENT_NODE,
ctdb_db->db_id);
if (status == 1) {
DEBUG(DEBUG_NOTICE, (__location__ " transaction is active "
"on db_id[%u]. waiting for 1 second\n",
ctdb_db->db_id));
sleep(1);
goto again;
}
tmp_ctx = talloc_new(h);
rh = ctdb_fetch_lock(ctdb_db, tmp_ctx, key, NULL);

View File

@ -56,7 +56,7 @@ case $cmd in
;;
monitor)
# always create these direcotries since NFS might be enabled at runtime
# always create these direcotries since NFS might be enabled at runtime
# and we dont want to restart ctdbd
mkdir -p $CTDB_BASE/state/nfstickle
mkdir -p $NFS_TICKLE_SHARED_DIRECTORY/`hostname`

View File

@ -620,6 +620,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
CTDB_CONTROL_TRANSACTION_CANCEL = 113,
CTDB_CONTROL_REGISTER_NOTIFY = 114,
CTDB_CONTROL_DEREGISTER_NOTIFY = 115,
CTDB_CONTROL_TRANS2_ACTIVE = 116,
};
/*
@ -1469,6 +1470,8 @@ int32_t ctdb_control_trans2_finished(struct ctdb_context *ctdb,
struct ctdb_req_control *c);
int32_t ctdb_control_trans2_error(struct ctdb_context *ctdb,
struct ctdb_req_control *c);
int32_t ctdb_control_trans2_active(struct ctdb_context *ctdb,
uint32_t db_id);
char *ctdb_addr_to_str(ctdb_sock_addr *addr);
unsigned ctdb_addr_to_port(ctdb_sock_addr *addr);

View File

@ -424,6 +424,10 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
case CTDB_CONTROL_TRANS2_FINISHED:
return ctdb_control_trans2_finished(ctdb, c);
case CTDB_CONTROL_TRANS2_ACTIVE:
CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
return ctdb_control_trans2_active(ctdb, *(uint32_t *)indata.dptr);
case CTDB_CONTROL_RECD_PING:
CHECK_CONTROL_DATA_SIZE(0);
return ctdb_control_recd_ping(ctdb);

View File

@ -604,6 +604,26 @@ int32_t ctdb_control_trans2_error(struct ctdb_context *ctdb,
return 0;
}
/**
* Tell whether a transaction is active on this node on the give DB.
*/
int32_t ctdb_control_trans2_active(struct ctdb_context *ctdb,
uint32_t db_id)
{
struct ctdb_db_context *ctdb_db;
ctdb_db = find_ctdb_db(ctdb, db_id);
if (!ctdb_db) {
DEBUG(DEBUG_ERR,(__location__ " Unknown db 0x%08x\n", db_id));
return -1;
}
if (ctdb_db->transaction_active) {
return 1;
} else {
return 0;
}
}
/*
backwards compatibility:

View File

@ -318,7 +318,7 @@ static int control_uptime(struct ctdb_context *ctdb, int argc, const char **argv
}
if (options.machinereadable){
printf(":Current Node Time:Ctdb Start Time:Last Recovery/Failover Time:Last Recovery/IPFailover Duration:\n");
printf(":Current Node Time:Ctdb Start Time:Last Recovery Time:Last Recovery Duration:\n");
printf(":%u:%u:%u:%lf\n",
(unsigned int)uptime->current_time.tv_sec,
(unsigned int)uptime->ctdbd_start_time.tv_sec,
@ -329,7 +329,7 @@ static int control_uptime(struct ctdb_context *ctdb, int argc, const char **argv
return 0;
}
printf("Current time of node : %s", ctime(&uptime->current_time.tv_sec));
printf("Current time of node : %s", ctime(&uptime->current_time.tv_sec));
tmp = uptime->current_time.tv_sec - uptime->ctdbd_start_time.tv_sec;
seconds = tmp%60;
@ -339,7 +339,7 @@ static int control_uptime(struct ctdb_context *ctdb, int argc, const char **argv
hours = tmp%24;
tmp /= 24;
days = tmp;
printf("Ctdbd start time : (%03d %02d:%02d:%02d) %s", days, hours, minutes, seconds, ctime(&uptime->ctdbd_start_time.tv_sec));
printf("Ctdbd start time : (%03d %02d:%02d:%02d) %s", days, hours, minutes, seconds, ctime(&uptime->ctdbd_start_time.tv_sec));
tmp = uptime->current_time.tv_sec - uptime->last_recovery_finished.tv_sec;
seconds = tmp%60;
@ -349,9 +349,9 @@ static int control_uptime(struct ctdb_context *ctdb, int argc, const char **argv
hours = tmp%24;
tmp /= 24;
days = tmp;
printf("Time of last recovery/failover: (%03d %02d:%02d:%02d) %s", days, hours, minutes, seconds, ctime(&uptime->last_recovery_finished.tv_sec));
printf("Time of last recovery : (%03d %02d:%02d:%02d) %s", days, hours, minutes, seconds, ctime(&uptime->last_recovery_finished.tv_sec));
printf("Duration of last recovery/failover: %lf seconds\n",
printf("Duration of last recovery : %lf seconds\n",
timeval_delta(&uptime->last_recovery_finished,
&uptime->last_recovery_started));