Skip to content

Commit

Permalink
Revert "Merged PR 685164: Forward rocksdb logs to Kusto"
Browse files Browse the repository at this point in the history
This reverts commit 60bffd1.
  • Loading branch information
semihokur committed Nov 16, 2022
1 parent 2a109b4 commit 8a8e771
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.SymbolStore;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
Expand All @@ -14,6 +17,7 @@
using BuildXL.Cache.ContentStore.Distributed.NuCache;
using BuildXL.Cache.ContentStore.FileSystem;
using BuildXL.Cache.ContentStore.Hashing;
using BuildXL.Cache.ContentStore.Interfaces.Extensions;
using BuildXL.Cache.ContentStore.Interfaces.FileSystem;
using BuildXL.Cache.ContentStore.Interfaces.Results;
using BuildXL.Cache.ContentStore.Interfaces.Synchronization;
Expand All @@ -28,16 +32,18 @@
using BuildXL.Native.IO;
using BuildXL.Utilities;
using BuildXL.Utilities.Collections;
using BuildXL.Utilities.Serialization;
using BuildXL.Utilities.Tasks;
using RocksDbSharp;
using static BuildXL.Cache.ContentStore.Distributed.MetadataService.RocksDbOperations;
using static BuildXL.Engine.Cache.KeyValueStores.RocksDbStore;
using AbsolutePath = BuildXL.Cache.ContentStore.Interfaces.FileSystem.AbsolutePath;

#nullable enable

namespace BuildXL.Cache.ContentStore.Distributed.MetadataService
{
using static RocksDbOperations;

public class RocksDbContentMetadataDatabaseConfiguration : RocksDbContentLocationDatabaseConfiguration
{
public RocksDbContentMetadataDatabaseConfiguration(AbsolutePath storeLocation)
Expand All @@ -54,7 +60,7 @@ public RocksDbContentMetadataDatabaseConfiguration(AbsolutePath storeLocation)
}

/// <summary>
/// RocksDb-based version of <see cref="ContentLocationDatabase"/> used by the global location store.
/// RocksDb-based version of <see cref="ContentLocationDatabase"/>.
/// </summary>
public class RocksDbContentMetadataDatabase : ContentLocationDatabase
{
Expand Down Expand Up @@ -283,27 +289,23 @@ private BoolResult Load(OperationContext context, StoreSlot activeSlot, bool cle
var dbAlreadyExists = Directory.Exists(storeLocation);
Directory.CreateDirectory(storeLocation);

var settings = new RocksDbStoreConfiguration(storeLocation)
{
AdditionalColumns = ColumnNames.SelectMany(n => n),
RotateLogsMaxFileSizeBytes = 0L,
RotateLogsNumFiles = 60,
RotateLogsMaxAge = TimeSpan.FromHours(12),
EnableStatistics = true,
FastOpen = true,
LeveledCompactionDynamicLevelTargetSizes = true,
Compression = Compression.Zstd,
UseReadOptionsWithSetTotalOrderSeekInDbEnumeration = true,
UseReadOptionsWithSetTotalOrderSeekInGarbageCollection = true,
MergeOperators = GetMergeOperators()
};

RocksDbUtilities.ConfigureRocksDbTracingIfNeeded(context, _configuration, settings, Tracer, componentName: nameof(RocksDbContentMetadataDatabase));

Tracer.Info(context, $"Creating RocksDb store at '{storeLocation}'. Clean={clean}, Configured Epoch='{_configuration.Epoch}', TracingLevel={_configuration.RocksDbTracingLevel}");
Tracer.Info(context, $"Creating RocksDb store at '{storeLocation}'. Clean={clean}, Configured Epoch='{_configuration.Epoch}'");

var possibleStore = KeyValueStoreAccessor.Open(
settings,
new RocksDbStoreConfiguration(storeLocation)
{
AdditionalColumns = ColumnNames.SelectMany(n => n),
RotateLogsMaxFileSizeBytes = 0L,
RotateLogsNumFiles = 60,
RotateLogsMaxAge = TimeSpan.FromHours(12),
EnableStatistics = true,
FastOpen = true,
LeveledCompactionDynamicLevelTargetSizes = true,
Compression = Compression.Zstd,
UseReadOptionsWithSetTotalOrderSeekInDbEnumeration = true,
UseReadOptionsWithSetTotalOrderSeekInGarbageCollection = true,
MergeOperators = GetMergeOperators()
},
// When an exception is caught from within methods using the database, this handler is called to
// decide whether the exception should be rethrown in user code, and the database invalidated. Our
// policy is to only invalidate if it is an exception coming from RocksDb, but not from our code.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using BuildXL.Cache.ContentStore.Distributed.NuCache.InMemory;
using BuildXL.Cache.ContentStore.Interfaces.FileSystem;
using BuildXL.Cache.Host.Configuration;
using RocksDbSharp;
using static BuildXL.Utilities.ConfigurationHelper;

#nullable enable
Expand Down Expand Up @@ -61,12 +60,6 @@ public abstract class ContentLocationDatabaseConfiguration
/// </summary>
public bool TraceOperations { get; set; } = true;

/// <summary>
/// Ges or sets log level from RocksDb emitted to Kusto.
/// Null - the tracing is off.
/// </summary>
public LogLevel? RocksDbTracingLevel { get; set; }

/// <summary>
/// Specifies whether to trace touches or not.
/// Tracing touches is expensive in terms of the amount of traffic to Kusto and in terms of memory traffic.
Expand Down Expand Up @@ -240,7 +233,6 @@ public static RocksDbContentLocationDatabaseConfiguration FromDistributedContent

configuration.RocksDbPerformanceSettings = settings.RocksDbPerformanceSettings;

ApplyIfNotNull(settings.ContentLocationDatabaseRocksDbTracingLevel, v => configuration.RocksDbTracingLevel = (LogLevel)v);
ApplyIfNotNull(settings.TraceStateChangeDatabaseOperations, v => configuration.TraceOperations = v);
ApplyIfNotNull(settings.TraceNoStateChangeDatabaseOperations, v => configuration.TraceNoStateChangeOperations = v);

Expand All @@ -249,7 +241,7 @@ public static RocksDbContentLocationDatabaseConfiguration FromDistributedContent
ApplyIfNotNull(settings.ContentLocationDatabaseMetadataGarbageCollectionMaximumSizeMb, v => configuration.MetadataGarbageCollectionMaximumSizeMb = v);
ApplyIfNotNull(settings.ContentLocationDatabaseMetadataGarbageCollectionLogEnabled, v => configuration.MetadataGarbageCollectionLogEnabled = v);

ApplyIfNotNull(settings.ContentLocationDatabaseOpenReadOnly, v => configuration.OpenReadOnly = (v && !settings.IsMasterEligible));
ApplyIfNotNull(settings.ContentLocationDatabaseOpenReadOnly, v => configuration.OpenReadOnly = v && !settings.IsMasterEligible);
ApplyIfNotNull(settings.UseMergeOperatorForContentLocations, v => configuration.UseMergeOperatorForContentLocations = v);

if (settings.ContentLocationDatabaseLogsBackupEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using BuildXL.Cache.ContentStore.Distributed.MetadataService;
using BuildXL.Cache.ContentStore.FileSystem;
using BuildXL.Cache.ContentStore.Hashing;
using BuildXL.Cache.ContentStore.Interfaces.Extensions;
Expand All @@ -27,6 +26,7 @@
using BuildXL.Engine.Cache.KeyValueStores;
using BuildXL.Native.IO;
using BuildXL.Utilities;
using BuildXL.Utilities.Collections;
using BuildXL.Utilities.ConfigurationHelpers;
using BuildXL.Utilities.Serialization;
using BuildXL.Utilities.Tasks;
Expand Down Expand Up @@ -225,7 +225,7 @@ private BoolResult Load(OperationContext context, StoreSlot activeSlot, bool cle
bool dbAlreadyExists = Directory.Exists(storeLocation);
Directory.CreateDirectory(storeLocation);

Tracer.Info(context, $"Creating RocksDb store at '{storeLocation}'. Clean={clean}, UseMergeOperators={_configuration.UseMergeOperatorForContentLocations}, Configured Epoch='{_configuration.Epoch}', TracingLevel={_configuration.RocksDbTracingLevel}");
Tracer.Info(context, $"Creating RocksDb store at '{storeLocation}'. Clean={clean}, UseMergeOperators={_configuration.UseMergeOperatorForContentLocations}, Configured Epoch='{_configuration.Epoch}'");

var settings = new RocksDbStoreConfiguration(storeLocation)
{
Expand Down Expand Up @@ -255,8 +255,6 @@ private BoolResult Load(OperationContext context, StoreSlot activeSlot, bool cle
UseReadOptionsWithSetTotalOrderSeekInGarbageCollection = _configuration.UseReadOptionsWithSetTotalOrderSeekInGarbageCollection,
};

RocksDbUtilities.ConfigureRocksDbTracingIfNeeded(context, _configuration, settings, Tracer, componentName: nameof(RocksDbContentLocationDatabase));

if (_configuration.UseMergeOperatorForContentLocations)
{
var mergeContext = context.CreateNested(nameof(RocksDbContentLocationDatabase), caller: "MergeContentLocationEntries");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ private RocksDbContentMetadataStore CreateRocksDbContentMetadataStore()
MetadataSizeRotationThreshold = DistributedContentSettings.GlobalCacheMetadataSizeRotationThreshold,
};

ApplyIfNotNull(DistributedContentSettings.ContentMetadataDatabaseRocksDbTracingLevel, v => dbConfig.RocksDbTracingLevel = (RocksDbSharp.LogLevel)v);
ApplyIfNotNull(DistributedContentSettings.LocationEntryExpiryMinutes, v => dbConfig.ContentRotationInterval = TimeSpan.FromMinutes(v));
dbConfig.MetadataRotationInterval = DistributedContentSettings.ContentMetadataServerMetadataRotationInterval;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,6 @@ public void DisableRedis()
[DataMember]
public bool? TraceStateChangeDatabaseOperations { get; set; }

/// <summary>
/// Defines a tracing level used by RocksDb logging adapter.
/// </summary>
/// <remarks>
/// See RocksDbSharp.LogLevel. The levels are:
/// 0 - Debug,
/// 1 - Info,
/// 2 - Warn,
/// 3 - Error,
/// 4 - Fatal,
/// 5 - Header
/// </remarks>
[DataMember]
public int? ContentLocationDatabaseRocksDbTracingLevel { get; set; } = 0;

[DataMember]
public bool TraceTouches { get; set; } = true;

Expand Down Expand Up @@ -967,10 +952,6 @@ public void DisableRedis()
[DataMember]
public bool ContentMetadataUseMergeWrites { get; set; }

/// <inheritdoc cref="ContentLocationDatabaseRocksDbTracingLevel"/>
[DataMember]
public int? ContentMetadataDatabaseRocksDbTracingLevel { get; set; } = 0;

[DataMember]
public string ContentMetadataBlobSecretName { get; set; }

Expand Down
15 changes: 0 additions & 15 deletions Public/Src/Utilities/KeyValueStore/RocksDb/RocksDbStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ private record struct ColumnFamilyInfo

private readonly RocksDbStoreConfiguration? m_options;

private readonly RocksDbLoggingAdapter? m_loggingAdapter;

/// <summary>
/// Encapsulates <see cref="RocksDb"/> options that should be set.
/// </summary>
Expand Down Expand Up @@ -156,12 +154,6 @@ public RocksDbStore(RocksDbStoreConfiguration configuration)
// }
.IncreaseParallelism(performanceConfiguration.GetBackgroundCompactionActualThreadCount());

if (configuration.HandleLogMessage != null)
{
m_loggingAdapter = new RocksDbLoggingAdapter(configuration.HandleLogMessage);
m_defaults.DbOptions = m_defaults.DbOptions.SetInfoLog(m_loggingAdapter);
}

if (performanceConfiguration.DbWriteBufferSize is { } dbWriteBufferSize)
{
m_defaults.DbOptions.SetDbWriteBufferSize(dbWriteBufferSize);
Expand Down Expand Up @@ -244,11 +236,6 @@ public RocksDbStore(RocksDbStoreConfiguration configuration)
.SetPrefixExtractor(SliceTransform.CreateNoOp())
.SetLevelCompactionDynamicLevelBytes(configuration.LeveledCompactionDynamicLevelTargetSizes);

if (configuration.HandleLogMessage != null)
{
options = options.SetInfoLogLevel((int)configuration.LogLevel);
}

ColumnFamilyPerformanceConfiguration? perfConfiguration = null;
if (name != null)
{
Expand Down Expand Up @@ -965,9 +952,7 @@ public void Dispose()
}
}

// Disabling the log to avoid execution engine exceptions by calling deleted delegates
m_store.Dispose();
m_loggingAdapter?.Dispose();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using BuildXL.Utilities.Collections;
using RocksDbSharp;

namespace BuildXL.Engine.Cache.KeyValueStores
Expand Down Expand Up @@ -160,14 +161,6 @@ public record RocksDbStoreConfiguration(string StoreDirectory)
/// </remarks>
public bool UseReadOptionsWithSetTotalOrderSeekInGarbageCollection { get; init; } = true;

/// <summary>
/// Log handler that will be called once rocksdb traces a message.
/// </summary>
public LogLineCallback? HandleLogMessage { get; set; }

/// <nodoc />
public LogLevel LogLevel { get; set; } = LogLevel.Info;

/// <nodoc />
public RocksDbPerformanceConfiguration PerformanceConfiguration { get; set; } = new RocksDbPerformanceConfiguration();
}
Expand Down
4 changes: 2 additions & 2 deletions cg/nuget/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2643,7 +2643,7 @@
"Type": "NuGet",
"NuGet": {
"Name": "RocksDbNative",
"Version": "6.10.2-b20221102.4"
"Version": "6.10.2-b20220621.2"
}
}
},
Expand All @@ -2652,7 +2652,7 @@
"Type": "NuGet",
"NuGet": {
"Name": "RocksDbSharp",
"Version": "6.10.2-b20221102.4"
"Version": "6.10.2-b20220621.2"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions config.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ config({
{ id: "Microsoft.Windows.ProjFS", version: "1.2.19351.1" },

// RocksDb
{ id: "RocksDbSharp", version: "6.10.2-b20221102.4", alias: "RocksDbSharpSigned",
{ id: "RocksDbSharp", version: "6.10.2-b20220621.2", alias: "RocksDbSharpSigned",
dependentPackageIdsToSkip: [ "System.Memory" ],
dependentPackageIdsToIgnore: [ "System.Memory" ]
},
{ id: "RocksDbNative", version: "6.10.2-b20221102.4" },
{ id: "RocksDbNative", version: "6.10.2-b20220621.2" },

{ id: "JsonDiffPatch.Net", version: "2.1.0" },

Expand Down

0 comments on commit 8a8e771

Please sign in to comment.