fix(channelserver): prevent guild RP rollover race and redundant stepup query

RolloverDailyRP now locks the guild row with SELECT FOR UPDATE and
re-checks rp_reset_at inside the transaction, so concurrent callers
cannot double-rollover and zero out freshly donated RP.

Gacha stepup entry-type check is now skipped when the row was already
deleted as stale, avoiding a redundant DELETE on step 0.
This commit is contained in:
Houmgaor
2026-02-21 00:53:10 +01:00
parent f584c5a688
commit 87040c55bb
2 changed files with 23 additions and 7 deletions

View File

@@ -327,14 +327,15 @@ func handleMsgMhfGetStepupStatus(s *Session, p mhfpacket.MHFPacket) {
s.logger.Error("Failed to reset stale gacha stepup", zap.Error(err))
}
step = 0
}
hasEntry, _ := s.server.gachaRepo.HasEntryType(pkt.GachaID, step)
if !hasEntry {
if err := s.server.gachaRepo.DeleteStepup(pkt.GachaID, s.charID); err != nil {
s.logger.Error("Failed to reset gacha stepup state", zap.Error(err))
} else if err == nil {
// Only check for valid entry type if the stepup is fresh
hasEntry, _ := s.server.gachaRepo.HasEntryType(pkt.GachaID, step)
if !hasEntry {
if err := s.server.gachaRepo.DeleteStepup(pkt.GachaID, s.charID); err != nil {
s.logger.Error("Failed to reset gacha stepup state", zap.Error(err))
}
step = 0
}
step = 0
}
bf := byteframe.NewByteFrame()
bf.WriteUint8(step)