Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Adaptors/MongoDB/src/Options/MongoDB.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// This file is part of the ArmoniK project
//
//
// Copyright (C) ANEO, 2021-2025. All rights reserved.
//
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

Expand Down Expand Up @@ -135,4 +135,10 @@ public class MongoDB
/// Authentication source for the MongoDB connection.
/// </summary>
public string AuthSource { get; set; } = "";

/// <summary>
/// Indicates whether to use minimal indexes for the collections.
/// </summary>
public bool UseMinimalIndexes { get; set; } = false;

}
32 changes: 19 additions & 13 deletions Adaptors/MongoDB/src/Table/DataModel/TaskDataModelMapping.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// This file is part of the ArmoniK project
//
//
// Copyright (C) ANEO, 2021-2025. All rights reserved.
//
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

Expand Down Expand Up @@ -191,25 +191,31 @@ public async Task InitializeIndexesAsync(IClientSessionHandle sessionHandl
IMongoCollection<TaskData> collection,
Options.MongoDB options)
{
var indexModels = new[]
var indexModels = new List<CreateIndexModel<TaskData>>
{
IndexHelper.CreateHashedIndex<TaskData>(model => model.Status),
IndexHelper.CreateHashedIndex<TaskData>(model => model.Options.PartitionId),
IndexHelper.CreateHashedIndex<TaskData>(model => model.SessionId),
IndexHelper.CreateHashedIndex<TaskData>(model => model.OwnerPodId),
IndexHelper.CreateHashedIndex<TaskData>(model => model.InitialTaskId),
IndexHelper.CreateHashedIndex<TaskData>(model => model.CreatedBy),
IndexHelper.CreateAscendingIndex<TaskData>(model => model.CreationDate,
expireAfter: options.DataRetention),
IndexHelper.CreateAscendingIndex<TaskData>(model => model.SubmittedDate),
IndexHelper.CreateAscendingIndex<TaskData>(model => model.StartDate),
IndexHelper.CreateAscendingIndex<TaskData>(model => model.EndDate),
IndexHelper.CreateAscendingIndex<TaskData>(model => model.CreationToEndDuration),
IndexHelper.CreateAscendingIndex<TaskData>(model => model.ProcessingToEndDuration),
IndexHelper.CreateCombinedIndex<TaskData>(model => model.Options.PartitionId,
model => model.Status),
};

if (options.UseMinimalIndexes == false)
{
indexModels.AddRange([
IndexHelper.CreateHashedIndex<TaskData>(model => model.OwnerPodId),
IndexHelper.CreateAscendingIndex<TaskData>(model => model.CreationDate,
expireAfter: options.DataRetention),
IndexHelper.CreateAscendingIndex<TaskData>(model => model.SubmittedDate),
IndexHelper.CreateAscendingIndex<TaskData>(model => model.StartDate),
IndexHelper.CreateAscendingIndex<TaskData>(model => model.EndDate),
IndexHelper.CreateAscendingIndex<TaskData>(model => model.CreationToEndDuration),
IndexHelper.CreateAscendingIndex<TaskData>(model => model.ProcessingToEndDuration),
]);
}

await collection.Indexes.CreateManyAsync(sessionHandle,
indexModels)
.ConfigureAwait(false);
Expand Down
20 changes: 13 additions & 7 deletions Adaptors/MongoDB/src/TaskTable.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// This file is part of the ArmoniK project
//
//
// Copyright (C) ANEO, 2021-2025. All rights reserved.
//
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

Expand Down Expand Up @@ -409,9 +409,15 @@ await taskCollection.UpdateManyAsync(sessionHandle,
cancellationToken: cancellationToken)
.ConfigureAwait(false);

var readyTasks = taskCollection.Find(sessionHandle,
data => taskIds.Contains(data.TaskId) && (data.Status == TaskStatus.Creating || data.Status == TaskStatus.Pending) &&
data.RemainingDataDependencies == new Dictionary<string, bool>())
var emptyDictionary = new Dictionary<string, bool>();

var filter = Builders<TaskData>.Filter.In(t => t.TaskId, taskIds)
& Builders<TaskData>.Filter.Or(Builders<TaskData>.Filter.Eq(t => t.Status, TaskStatus.Creating),
Builders<TaskData>.Filter.Eq(t => t.Status,TaskStatus.Pending))
& Builders<TaskData>.Filter.Eq(t => t.RemainingDataDependencies,
emptyDictionary);

var readyTasks = taskCollection.Find(filter)
.Project(selector)
.ToAsyncEnumerable(cancellationToken);

Expand Down
3 changes: 2 additions & 1 deletion Compute/PollingAgent/src/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
},
"ObjectStorage": {
"ChunkSize": "100000"
}
},
"UseMinimalIndexes" : true
},
"Amqp": {
"MaxRetries": "10",
Expand Down
3 changes: 2 additions & 1 deletion Control/Metrics/src/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
},
"ObjectStorage": {
"ChunkSize": "100000"
}
},
"UseMinimalIndexes": true
},
"Amqp": {
"MaxRetries": "10",
Expand Down
3 changes: 2 additions & 1 deletion Control/PartitionMetrics/src/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"LockRefreshPeriodicity": "00:20:00",
"PollPeriodicity": "00:00:50",
"LockRefreshExtension": "00:50:00"
}
},
"UseMinimalIndexes": true
},
"Amqp": {
"MaxRetries": "10",
Expand Down
3 changes: 2 additions & 1 deletion Control/Submitter/src/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
},
"ObjectStorage": {
"ChunkSize": "100000"
}
},
"UseMinimalIndexes": true
},
"Amqp": {
"MaxRetries": "10",
Expand Down
Loading