Well,不要刷屏了

es translog 切换时的延时

Elasticsearch | 作者 wahahawa | 发布于2021年06月03日 | 阅读数:935

从代码来看,translog切换时,需要先关闭旧的,然后打开新的,在这个时间段内(从日志看应该是ms级别)来的请求,延迟是不是比正常情况下要高,从而形成一个小尖峰.
下面是切换translog的源码
public void rollGeneration() throws IOException {
syncBeforeRollGeneration();
if (current.totalOperations() == 0 && primaryTermSupplier.getAsLong() == current.getPrimaryTerm()) {
return;
}
try (Releasable ignored = writeLock.acquire()) {
ensureOpen();
try {
final TranslogReader reader = current.closeIntoReader();
readers.add(reader);
assert Checkpoint.read(location.resolve(CHECKPOINT_FILE_NAME)).generation == current.getGeneration();
copyCheckpointTo(location.resolve(getCommitCheckpointFileName(current.getGeneration())));
// create a new translog file; this will sync it and update the checkpoint data;
current = createWriter(current.getGeneration() + 1);
logger.trace("current translog set to [{}]", current.getGeneration());
} catch (final Exception e) {
tragedy.setTragicException(e);
closeOnTragicEvent(e);
throw e;
}
}
}
已邀请:

Charele - Cisco4321

赞同来自:

translog切换只有在ES flush时才会发生,
自动flush的发生要日志达到一定数量,
除非你每写一个数据就执行手动flush,没人会这么做
 

要回复问题请先登录注册