Can't run TinyKV with TinySQL
Moonm3n opened this issue · 2 comments
Moonm3n commented
In the default configuration, SchedulerHeartbeatTickInterval
is less than RaftBaseTickInterval
.
func NewDefaultConfig() *Config {
return &Config{
SchedulerAddr: "127.0.0.1:2379",
StoreAddr: "127.0.0.1:20160",
LogLevel: getLogLevel(),
Raft: true,
// RaftBaseTickInterval is one seconde.
RaftBaseTickInterval: 1 * time.Second,
RaftHeartbeatTicks: 2,
RaftElectionTimeoutTicks: 10,
RaftLogGCTickInterval: 10 * time.Second,
RaftLogGcCountLimit: 128000,
SplitRegionCheckTickInterval: 10 * time.Second,
// SchedulerHeartbeatTickInterval is one hundred milliseconds.
SchedulerHeartbeatTickInterval: 100 * time.Millisecond,
SchedulerStoreHeartbeatTickInterval: 10 * time.Second,
RegionMaxSize: 144 * MB,
RegionSplitSize: 96 * MB,
DBPath: "/tmp/badger",
}
}
So Raft leader will never send heartbeat to the scheduler, the scheduler will never get the region information too.
TinySQL gets the following error:
[FATAL] [session.go:864] ["check bootstrapped failed"] [error="[tikv:9001]PD server timeout"]
Connor1996 commented
why if it's less than raft base tick interval, raft leader never send heartbeat to the scheduler
Moonm3n commented
The use of "never" isn't quite accurate. To be precise, leaders will never send RegionHeartbeat
by tick.
The interval of PeerTickSchedulerHeartbeat
is equal to SchedulerHeartbeatTickInterval
divided by RaftBaseTickInterval
.
t.schedules[int(PeerTickSchedulerHeartbeat)].interval = int64(cfg.SchedulerHeartbeatTickInterval / baseInterval)
The result of it is 0, so PeerTickSchedulerHeartbeat
will not be scheduled.
func (t *ticker) schedule(tp PeerTick) {
sched := &t.schedules[int(tp)]
if sched.interval <= 0 {
sched.runAt = -1
return
}
sched.runAt = t.tick + sched.interval
}
Leaders will never send RegionHeartbeat
by tick.
func (d *peerMsgHandler) onTick() {
if d.stopped {
return
}
d.ticker.tickClock()
if d.ticker.isOnTick(PeerTickRaft) {
d.onRaftBaseTick()
}
if d.ticker.isOnTick(PeerTickRaftLogGC) {
d.onRaftGCLogTick()
}
if d.ticker.isOnTick(PeerTickSchedulerHeartbeat) { // always false
d.onSchedulerHeartbeatTick()
}
if d.ticker.isOnTick(PeerTickSplitRegionCheck) {
d.onSplitRegionCheckTick()
}
d.ctx.tickDriverSender <- d.regionId
}
func (d *peerMsgHandler) onSchedulerHeartbeatTick() {
d.ticker.schedule(PeerTickSchedulerHeartbeat)
if !d.IsLeader() {
return
}
d.HeartbeatScheduler(d.ctx.schedulerTaskSender)
}