Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

filer mongodb add option poll size and fixed order by list meta

buktond6d245dc895e
diff --git a/weed/filer2/mongodb/mongodb_store.go b/weed/filer2/mongodb/mongodb_store.go
index 965634947b..4e78c54a4d 100644
--- a/weed/filer2/mongodb/mongodb_store.go
+++ b/weed/filer2/mongodb/mongodb_store.go
@@ -36,12 +36,19 @@ func (store *MongodbStore) GetName() string {
func (store *MongodbStore) Initialize(configuration util.Configuration, prefix string) (err error) {
store.database = configuration.GetString(prefix + "database")
store.collectionName = "filemeta"
- return store.connection(configuration.GetString(prefix + "uri"))
+ poolSize := configuration.GetInt(prefix + "option_pool_size")
+ return store.connection(configuration.GetString(prefix + "uri"), uint64(poolSize))
}
-func (store *MongodbStore) connection(uri string) (err error) {
+func (store *MongodbStore) connection(uri string, poolSize uint64) (err error) {
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
- client, err := mongo.Connect(ctx, options.Client().ApplyURI(uri))
+ opts := options.Client().ApplyURI(uri)
+
+ if poolSize > 0 {
+ opts.SetMaxPoolSize(poolSize)
+ }
+
+ client, err := mongo.Connect(ctx, opts)
store.connect = client
return err
}
@@ -141,7 +148,8 @@ func (store *MongodbStore) ListDirectoryEntries(ctx context.Context, fullpath ut
}
}
optLimit := int64(limit)
- cur, err := store.connect.Database(store.database).Collection(store.collectionName).Find(ctx, where, &options.FindOptions{Limit: &optLimit})
+ opts := &options.FindOptions{Limit: &optLimit, Sort: bson.M{ "name": 1 }}
+ cur, err := store.connect.Database(store.database).Collection(store.collectionName).Find(ctx, where, opts)
for cur.Next(ctx) {
var data Model
err := cur.Decode(&data)