Skip to content

Feature/instrument create database #21757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 37 commits into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
63b4c94
Fix exec context for future coroutines
jvolmer May 6, 2025
ed28bb5
Extract context variables into struct
jvolmer May 6, 2025
5a6f303
Add constructor to context
jvolmer May 6, 2025
892a501
Extract source location
jvolmer Apr 4, 2025
eab010c
Add task registry
jvolmer Apr 4, 2025
d05e567
Add global task registry variable
jvolmer Apr 22, 2025
0e3f1b6
Pass first test for a root task
jvolmer Apr 22, 2025
bcf4d44
Be able to set a parent node as a shared ref
jvolmer Apr 28, 2025
b6a78ac
Add tests for parent lifetime
jvolmer Apr 28, 2025
6a530c4
Add tests to arangodbtests
jvolmer Apr 28, 2025
a654059
Get rid of currently unused stuff
jvolmer Apr 28, 2025
fe9d1a9
Rename directory and namespace
jvolmer May 5, 2025
358ca7e
Do reference counting manually
jvolmer Apr 30, 2025
3570839
Mark for deletion up the hierarchy
jvolmer Apr 30, 2025
661119c
Make deleted property atomic
jvolmer May 5, 2025
1478d32
Use an enum instead of a string for the state
jvolmer May 5, 2025
0ff5982
Set state to Finished when task goes out of scope
jvolmer May 5, 2025
45bd994
Make really sure that node is not marked for deletion twice
jvolmer May 5, 2025
38ddf2c
Thread knows its current task
jvolmer May 5, 2025
ef6b4fe
Rename AsyncRegistryServer/ to SystemMonitor/AsyncRegistry
jvolmer Apr 29, 2025
f6c0739
Add task registry feature with metrics
jvolmer Apr 29, 2025
630053f
Move forest to lib
jvolmer Apr 30, 2025
0aff513
Add REST handler
jvolmer Apr 30, 2025
5b1fe64
Add metrics documentation
jvolmer May 6, 2025
08db83b
Move forest test to container tests
jvolmer May 6, 2025
ee7deac
Workaround: Print bare task registry in REST handler
jvolmer May 8, 2025
f906ef6
Fix bad alloc by moving entry struct into namespace
jvolmer May 8, 2025
fd1de2f
Instrumented Database Creation and UpgradeTasks
mchacki May 9, 2025
3922078
Merge branch 'feature/task-registry-feature' into feature/instrument-…
mchacki May 9, 2025
3e01a6e
Refactored MaintenanceActions to use a seperate folder.
mchacki May 9, 2025
7cb0c93
Instrumented Maintenance Actions
mchacki May 12, 2025
5fd52a0
Added a Pretty Printer for the RestEndpoint output
mchacki May 12, 2025
f5745a1
Next version on pretty printing
mchacki May 12, 2025
635317b
Updated the layout a bit. Running tasks are not Grouped
mchacki May 12, 2025
92f5e1d
Reversed order in Pretty printer
mchacki May 12, 2025
907b8b3
Added a show-deleted flag
mchacki May 12, 2025
6ca4f7a
Applied ClangFormat
mchacki May 13, 2025
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: 14 additions & 0 deletions Documentation/Metrics/arangodb_monitoring_tasks_existing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: arangodb_monitoring_tasks_existing
introducedIn: "3.12.5"
help: |
Number of currently existing monitoring tasks.
unit: number
type: gauge
category: Statistics
complexity: advanced
exposedBy:
- dbserver
- coordinator
- agent
description: |
Number of currently existing monitoring tasks.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: arangodb_monitoring_tasks_existing_thread_registries
introducedIn: "3.12.5"
help: |
Number of threads that started currently existing monitoring tasks.
unit: number
type: gauge
category: Statistics
complexity: advanced
exposedBy:
- dbserver
- coordinator
- agent
description: |
Number of threads that started currently existing monitoring tasks. The thread itself does not need to exist any more. This number also includes still running threads that have started monitoring tasks that do not exist any more.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: arangodb_monitoring_tasks_ready_for_deletion
introducedIn: "3.12.5"
help: |
Number of currently existing monitoring tasks that wait for their garbage collection.
unit: number
type: gauge
category: Statistics
complexity: advanced
exposedBy:
- dbserver
- coordinator
- agent
description: |
Number of currently existing monitoring tasks that wait for their garbage collection.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: arangodb_monitoring_tasks_thread_registries_total
introducedIn: "3.12.5"
help: |
Total number of threads that started monitoring tasks since database creation.
unit: number
type: counter
category: Statistics
complexity: advanced
exposedBy:
- dbserver
- coordinator
- agent
description: |
Total number of threads that started monitoring tasks since database creation.
14 changes: 14 additions & 0 deletions Documentation/Metrics/arangodb_monitoring_tasks_total.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: arangodb_monitoring_tasks_total
introducedIn: "3.12.5"
help: |
Total number of created monitoring tasks since database creation.
unit: number
type: counter
category: Statistics
complexity: advanced
exposedBy:
- dbserver
- coordinator
- agent
description: |
Total number of created monitoring tasks since database creation.
8 changes: 0 additions & 8 deletions arangod/AsyncRegistryServer/PrettyPrinter/.gdbinit

This file was deleted.

6 changes: 0 additions & 6 deletions arangod/AsyncRegistryServer/Stacktrace/CMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion arangod/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ get_target_property(IRESEARCH_INCLUDE
include(arangoserver.cmake)
add_subdirectory(Agency)
add_subdirectory(Aql)
add_subdirectory(AsyncRegistryServer)
add_subdirectory(Cache)
add_subdirectory(Cluster)
add_subdirectory(ClusterEngine)
Expand All @@ -118,6 +117,7 @@ add_subdirectory(RestHandler)
add_subdirectory(RestServer)
add_subdirectory(RocksDBEngine)
add_subdirectory(StorageEngine)
add_subdirectory(SystemMonitor)
add_subdirectory(Utils)
if (USE_V8)
add_subdirectory(V8Server)
Expand Down
2 changes: 1 addition & 1 deletion arangod/Cluster/Maintenance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "Cluster/ClusterFeature.h"
#include "Cluster/ClusterInfo.h"
#include "Cluster/FollowerInfo.h"
#include "Cluster/ResignShardLeadership.h"
#include "Cluster/MaintenanceActions/ResignShardLeadership.h"
#include "Indexes/Index.h"
#include "Inspection/VPack.h"
#include "IResearch/IResearchCommon.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
#include "Action.h"

#include "Basics/Exceptions.h"
#include "Cluster/CreateCollection.h"
#include "Cluster/CreateDatabase.h"
#include "Cluster/DropCollection.h"
#include "Cluster/DropDatabase.h"
#include "Cluster/DropIndex.h"
#include "Cluster/EnsureIndex.h"
#include "Cluster/MaintenanceActions/CreateCollection.h"
#include "Cluster/MaintenanceActions/CreateDatabase.h"
#include "Cluster/MaintenanceActions/DropCollection.h"
#include "Cluster/MaintenanceActions/DropDatabase.h"
#include "Cluster/MaintenanceActions/DropIndex.h"
#include "Cluster/MaintenanceActions/EnsureIndex.h"
#include "Cluster/MaintenanceStrings.h"
#include "Cluster/ResignShardLeadership.h"
#include "Cluster/SynchronizeShard.h"
#include "Cluster/TakeoverShardLeadership.h"
#include "Cluster/UpdateCollection.h"
#include "Cluster/UpdateReplicatedLogAction.h"
#include "Cluster/MaintenanceActions/ResignShardLeadership.h"
#include "Cluster/MaintenanceActions/SynchronizeShard.h"
#include "Cluster/MaintenanceActions/TakeoverShardLeadership.h"
#include "Cluster/MaintenanceActions/UpdateCollection.h"
#include "Cluster/MaintenanceActions/UpdateReplicatedLogAction.h"

using namespace arangodb;
using namespace arangodb::maintenance;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/// @author Matthew Von-Maszewski
////////////////////////////////////////////////////////////////////////////////

#include "Cluster/ActionBase.h"
#include "Cluster/MaintenanceActions/ActionBase.h"

#include "ApplicationFeatures/ApplicationServer.h"
#include "Basics/TimeString.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "Replication2/ReplicatedState/ReplicatedState.h"
#include "Replication2/StateMachines/Document/DocumentFollowerState.h"
#include "Replication2/StateMachines/Document/DocumentLeaderState.h"
#include "TaskMonitoring/task.h"

#include <velocypack/Compare.h>
#include <velocypack/Iterator.h>
Expand Down Expand Up @@ -112,6 +113,11 @@ bool CreateCollection::first() {
auto const& leader = _description.get(THE_LEADER);
auto const& props = properties();

// Add task monitoring
auto task = task_monitoring::Task{"CreateCollection for DB: '" + database +
"', Collection: '" + collection +
"', Shard: '" + shard + "'"};

std::string from;
_description.get("from", from);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "Utils/DatabaseGuard.h"
#include "Utils/OperationOptions.h"
#include "VocBase/Methods/Databases.h"
#include "TaskMonitoring/task.h"

using namespace arangodb;
using namespace arangodb::application_features;
Expand Down Expand Up @@ -69,6 +70,10 @@ bool CreateDatabase::first() {
VPackSlice users;
auto database = _description.get(DATABASE);

// Add task monitoring
auto task =
task_monitoring::Task{"CreateDatabase for DB: '" + database + "'"};

LOG_TOPIC("953b1", DEBUG, Logger::MAINTENANCE)
<< "CreateDatabase: creating database " << database;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "VocBase/Methods/Collections.h"
#include "VocBase/Methods/Databases.h"
#include "VocBase/vocbase.h"
#include "TaskMonitoring/task.h"

using namespace arangodb;
using namespace arangodb::application_features;
Expand Down Expand Up @@ -69,6 +70,10 @@ bool DropCollection::first() {
auto const& database = getDatabase();
auto const& shard = getShard();

// Add task monitoring
auto task = task_monitoring::Task{"DropCollection for DB: '" + database +
"', Shard: '" + shard + "'"};

LOG_TOPIC("a2961", DEBUG, Logger::MAINTENANCE)
<< "DropCollection: dropping local shard '" << database << "/" << shard;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "Utils/ExecContext.h"
#include "Utils/OperationOptions.h"
#include "VocBase/Methods/Databases.h"
#include "TaskMonitoring/task.h"

using namespace arangodb::application_features;
using namespace arangodb::methods;
Expand Down Expand Up @@ -69,6 +70,9 @@ bool DropDatabase::first() {
LOG_TOPIC("22779", DEBUG, Logger::MAINTENANCE)
<< "DropDatabase: dropping " << database;

// Add task monitoring
auto task = task_monitoring::Task{"DropDatabase for DB: '" + database + "'"};

try {
auto& df = _feature.server().getFeature<DatabaseFeature>();
DatabaseGuard guard(df, StaticStrings::SystemDatabase);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "VocBase/Methods/Collections.h"
#include "VocBase/Methods/Databases.h"
#include "VocBase/Methods/Indexes.h"
#include "TaskMonitoring/task.h"

using namespace arangodb::application_features;
using namespace arangodb::maintenance;
Expand Down Expand Up @@ -90,6 +91,11 @@ bool DropIndex::first() {
auto const& shard = _description.get(SHARD);
auto const& id = _description.get(INDEX);

// Add task monitoring
auto task =
task_monitoring::Task{"DropIndex for DB: '" + database + "', Shard: '" +
shard + "', Index: '" + id + "'"};

VPackBuilder index;
index.add(VPackValue(_description.get(INDEX)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "Utils/DatabaseGuard.h"
#include "VocBase/LogicalCollection.h"
#include "VocBase/Methods/Databases.h"
#include "TaskMonitoring/task.h"

using namespace arangodb;
using namespace arangodb::application_features;
Expand Down Expand Up @@ -114,6 +115,11 @@ bool EnsureIndex::first() {
auto const& shard = _description.get(SHARD);
auto const& id = properties().get(ID).copyString();

// Add task monitoring
auto task = task_monitoring::Task{"EnsureIndex for DB: '" + database +
"', Collection: '" + collection +
"', Shard: '" + shard + "'"};

try { // now try to guard the database
auto& df = _feature.server().getFeature<DatabaseFeature>();
DatabaseGuard guard(df, database);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "VocBase/LogicalCollection.h"
#include "VocBase/Methods/Collections.h"
#include "VocBase/Methods/Databases.h"
#include "TaskMonitoring/task.h"

#include <velocypack/Compare.h>
#include <velocypack/Iterator.h>
Expand Down Expand Up @@ -80,6 +81,11 @@ bool ResignShardLeadership::first() {
std::string const& database = getDatabase();
std::string const& collection = getShard();

// Add task monitoring
auto task =
task_monitoring::Task{"ResignShardLeadership for DB: '" + database +
"', Shard: '" + collection + "'"};

LOG_TOPIC("14f43", DEBUG, Logger::MAINTENANCE)
<< "trying to withdraw as leader of shard '" << database << "/"
<< collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
#include "Basics/TimeString.h"
#include "Basics/VelocyPackHelper.h"
#include "Basics/debugging.h"
#include "Cluster/ActionDescription.h"
#include "Cluster/MaintenanceActions/ActionDescription.h"
#include "Cluster/AgencyCache.h"
#include "Cluster/ClusterFeature.h"
#include "Cluster/ClusterInfo.h"
#include "Cluster/CollectionInfoCurrent.h"
#include "Cluster/FollowerInfo.h"
#include "Cluster/Maintenance.h"
#include "Cluster/MaintenanceFeature.h"
#include "Cluster/ResignShardLeadership.h"
#include "Cluster/MaintenanceActions/ResignShardLeadership.h"
#include "Cluster/ReplicationTimeoutFeature.h"
#include "Cluster/ServerState.h"
#include "GeneralServer/AuthenticationFeature.h"
Expand All @@ -66,6 +66,7 @@
#include "VocBase/LogicalCollection.h"
#include "VocBase/Methods/Collections.h"
#include "VocBase/Methods/Databases.h"
#include "TaskMonitoring/task.h"

#include <absl/strings/str_cat.h>
#include <velocypack/Compare.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#pragma once

#include "Basics/ResultT.h"
#include "Cluster/ActionBase.h"
#include "Cluster/ActionDescription.h"
#include "Cluster/MaintenanceActions/ActionBase.h"
#include "Cluster/MaintenanceActions/ActionDescription.h"
#include "Replication/utilities.h"
#include "VocBase/voc-types.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "VocBase/LogicalCollection.h"
#include "VocBase/Methods/Collections.h"
#include "VocBase/Methods/Databases.h"
#include "TaskMonitoring/task.h"

#include <velocypack/Compare.h>
#include <velocypack/Iterator.h>
Expand Down Expand Up @@ -267,6 +268,11 @@ bool TakeoverShardLeadership::first() {
uint64_t planIndex = basics::StringUtils::uint64(planRaftIndex);
Result res;

// Add task monitoring
auto task = task_monitoring::Task{"TakeoverShardLeadership for DB: '" +
database + "', Collection: '" + collection +
"', Shard: '" + shard + "'"};

try {
auto& df = _feature.server().getFeature<DatabaseFeature>();
DatabaseGuard guard(df, database);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "VocBase/LogicalCollection.h"
#include "VocBase/Methods/Collections.h"
#include "VocBase/Methods/Databases.h"
#include "TaskMonitoring/task.h"

using namespace arangodb;
using namespace arangodb::application_features;
Expand Down Expand Up @@ -89,6 +90,11 @@ bool UpdateCollection::first() {
auto const& props = properties();
Result res;

// Add task monitoring
auto task = task_monitoring::Task{"UpdateCollection for DB: '" + database +
"', Collection: '" + collection +
"', Shard: '" + shard + "'"};

std::string from;
_description.get("from", from);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "UpdateReplicatedLogAction.h"
#include "Utils/DatabaseGuard.h"
#include "VocBase/vocbase.h"
#include "TaskMonitoring/task.h"

using namespace arangodb;
using namespace arangodb::basics;
Expand All @@ -63,6 +64,11 @@ bool arangodb::maintenance::UpdateReplicatedLogAction::first() {
auto const& database = _description.get(DATABASE);
auto& df = _feature.server().getFeature<DatabaseFeature>();

// Add task monitoring
auto task =
task_monitoring::Task{"UpdateReplicatedLogAction for DB: '" + database +
"', LogId: '" + std::to_string(logId.id()) + "'"};

auto result = basics::catchToResult([&] {
DatabaseGuard guard(df, database);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#pragma once

#include "Cluster/ActionBase.h"
#include "Cluster/MaintenanceActions/ActionBase.h"

namespace arangodb::maintenance {

Expand Down
Loading