fix shared-db tenant runtime gaps
This commit is contained in:
+27
-4
@@ -238,6 +238,8 @@ func serveIMHTTPIdempotent(wrt http.ResponseWriter, req *http.Request, next http
|
||||
}
|
||||
existing, acquired, err := store.HTTPInfrastructure.BeginIdempotency(principal.TenantID, record)
|
||||
if err != nil {
|
||||
logs.Warn.Printf("im http idempotency begin failed request_id=%s tenant=%d user=%s method=%s route=%s err=%v",
|
||||
req.Header.Get("X-Request-ID"), principal.TenantID, principal.Uid.UserId(), req.Method, req.URL.Path, err)
|
||||
writeIMError(wrt, req, http.StatusInternalServerError, 90000, imReasonInternal, "internal error", nil)
|
||||
return
|
||||
}
|
||||
@@ -262,12 +264,20 @@ func serveIMHTTPIdempotent(wrt http.ResponseWriter, req *http.Request, next http
|
||||
record.ResponseStatus = buffered.status
|
||||
record.ResponseBody = append([]byte(nil), buffered.body.Bytes()...)
|
||||
if buffered.status >= http.StatusInternalServerError {
|
||||
_ = store.HTTPInfrastructure.AbortIdempotency(principal.TenantID, record)
|
||||
if abortErr := store.HTTPInfrastructure.AbortIdempotency(principal.TenantID, record); abortErr != nil {
|
||||
logs.Warn.Printf("im http idempotency abort failed request_id=%s tenant=%d user=%s method=%s route=%s err=%v",
|
||||
req.Header.Get("X-Request-ID"), principal.TenantID, principal.Uid.UserId(), req.Method, req.URL.Path, abortErr)
|
||||
}
|
||||
buffered.flushTo(wrt)
|
||||
return
|
||||
}
|
||||
if err = store.HTTPInfrastructure.CompleteIdempotency(principal.TenantID, record); err != nil {
|
||||
_ = store.HTTPInfrastructure.AbortIdempotency(principal.TenantID, record)
|
||||
logs.Warn.Printf("im http idempotency complete failed request_id=%s tenant=%d user=%s method=%s route=%s status=%d err=%v",
|
||||
req.Header.Get("X-Request-ID"), principal.TenantID, principal.Uid.UserId(), req.Method, req.URL.Path, buffered.status, err)
|
||||
if abortErr := store.HTTPInfrastructure.AbortIdempotency(principal.TenantID, record); abortErr != nil {
|
||||
logs.Warn.Printf("im http idempotency abort after complete failed request_id=%s tenant=%d user=%s method=%s route=%s err=%v",
|
||||
req.Header.Get("X-Request-ID"), principal.TenantID, principal.Uid.UserId(), req.Method, req.URL.Path, abortErr)
|
||||
}
|
||||
writeIMError(wrt, req, http.StatusInternalServerError, 90000, imReasonInternal, "internal error", nil)
|
||||
return
|
||||
}
|
||||
@@ -2063,8 +2073,21 @@ func serveIMAppReleaseLatest(wrt http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
release, err := store.AppReleases.Latest(platform, channel)
|
||||
if err != nil {
|
||||
writeIMRelationError(wrt, req, err)
|
||||
return
|
||||
if platform == "web" {
|
||||
logs.Warn.Println("im app release latest: using web fallback", err)
|
||||
release = &types.AppRelease{
|
||||
Platform: platform,
|
||||
Channel: channel,
|
||||
LatestVersion: currentVersion,
|
||||
MinSupportedVersion: currentVersion,
|
||||
UpdateType: "none",
|
||||
ReleaseNotes: "当前已是最新版本。",
|
||||
PublishedAt: time.Now().UTC(),
|
||||
}
|
||||
} else {
|
||||
writeIMRelationError(wrt, req, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
latestParts, latestErr := parseNumericAppVersion(release.LatestVersion)
|
||||
minimumParts, minimumErr := parseNumericAppVersion(release.MinSupportedVersion)
|
||||
|
||||
Reference in New Issue
Block a user