Infinite loop debug
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user