Skip to content

Commit

Permalink
mvcc: reduce log. (tikv#2550)
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing authored and zhangjinpeng87 committed Dec 7, 2017
1 parent d394a9a commit 2cf7d98
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/storage/mvcc/metrics.rs
Expand Up @@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use prometheus::{exponential_buckets, CounterVec, Histogram};
use prometheus::*;

lazy_static! {
pub static ref MVCC_VERSIONS_HISTOGRAM: Histogram =
Expand All @@ -35,4 +35,11 @@ lazy_static! {
"Total number of conflict error",
&["type"]
).unwrap();

pub static ref MVCC_DUPLICATE_CMD_COUNTER_VEC: CounterVec =
register_counter_vec!(
"tikv_storage_mvcc_duplicate_cmd_counter",
"Total number of duplicated commands",
&["type"]
).unwrap();
}
17 changes: 12 additions & 5 deletions src/storage/mvcc/txn.rs
Expand Up @@ -147,10 +147,9 @@ impl MvccTxn {
}
// No need to overwrite the lock and data.
// If we use single delete, we can't put a key multiple times.
info!(
"duplicated prewrite with start_ts {}, ignore it.",
self.start_ts
);
MVCC_DUPLICATE_CMD_COUNTER_VEC
.with_label_values(&["prewrite"])
.inc();
return Ok(());
}

Expand Down Expand Up @@ -209,7 +208,12 @@ impl MvccTxn {
// Committed by concurrent transaction.
Some((_, WriteType::Put)) |
Some((_, WriteType::Delete)) |
Some((_, WriteType::Lock)) => Ok(()),
Some((_, WriteType::Lock)) => {
MVCC_DUPLICATE_CMD_COUNTER_VEC
.with_label_values(&["commit"])
.inc();
Ok(())
}
};
}
};
Expand All @@ -236,6 +240,9 @@ impl MvccTxn {
Some((ts, write_type)) => {
if write_type == WriteType::Rollback {
// return Ok on Rollback already exist
MVCC_DUPLICATE_CMD_COUNTER_VEC
.with_label_values(&["rollback"])
.inc();
Ok(())
} else {
MVCC_CONFLICT_COUNTER
Expand Down

0 comments on commit 2cf7d98

Please sign in to comment.