Infinite loop debug

This commit is contained in:
mr
2026-03-23 09:03:07 +01:00
parent ea2a98d84a
commit 5bdd2554a7
2 changed files with 13 additions and 2 deletions

View File

@@ -267,6 +267,9 @@ func (m *MongoDB) LoadOne(id string, collection_name string) (*mongo.SingleResul
}
filter := bson.M{"_id": id}
targetDBCollection := CollectionMap[collection_name]
if targetDBCollection == nil {
return nil, 503, errors.New("collection " + collection_name + " not initialized")
}
MngoCtx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
//defer cancel()
@@ -286,6 +289,9 @@ func (m *MongoDB) Search(filters *dbs.Filters, collection_name string) (*mongo.C
opts := options.Find()
opts.SetLimit(1000)
targetDBCollection := CollectionMap[collection_name]
if targetDBCollection == nil {
return nil, 503, errors.New("collection " + collection_name + " not initialized")
}
f := dbs.GetBson(filters)

View File

@@ -4,6 +4,7 @@ import (
"errors"
"time"
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
"cloud.o-forge.io/core/oc-lib/logs"
"cloud.o-forge.io/core/oc-lib/models/common/enum"
"cloud.o-forge.io/core/oc-lib/models/utils"
@@ -44,7 +45,10 @@ func (a *BookingMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
now := time.Now()
now = now.Add(time.Second * -60)
if d.(*Booking).State == enum.DRAFT && now.UTC().After(d.(*Booking).ExpectedStartDate) {
return utils.GenericDeleteOne(d.GetID(), a)
// Direct raw delete to avoid infinite recursion:
// GenericDeleteOne calls a.LoadOne which would re-enter this callback.
mongo.MONGOService.DeleteOne(d.GetID(), a.GetType().String())
return nil, 410, errors.New("draft booking expired and deleted")
}
if (d.(*Booking).ExpectedEndDate) == nil {
d.(*Booking).State = enum.FORGOTTEN
@@ -62,7 +66,8 @@ func (a *BookingMongoAccessor) GetExec(isDraft bool) func(utils.DBObject) utils.
now := time.Now()
now = now.Add(time.Second * -60)
if d.(*Booking).State == enum.DRAFT && now.UTC().After(d.(*Booking).ExpectedStartDate) {
utils.GenericDeleteOne(d.GetID(), a)
// Direct raw delete to avoid infinite recursion (same as LoadOne callback).
mongo.MONGOService.DeleteOne(d.GetID(), a.GetType().String())
return nil
}
if d.(*Booking).State == enum.SCHEDULED && now.UTC().After(d.(*Booking).ExpectedStartDate) {