Skip to content

Users/nmalkapuram/postresqlhammerdbsupporton arm #560

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,29 @@ private Task ExecuteWorkloadAsync(EventContext telemetryContext, CancellationTok
{
using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken))
{
string command = "python3";
string script = $"{this.HammerDBPackagePath}/run-workload.py";

using (IProcessProxy process = await this.ExecuteCommandAsync(
command,
script + " " + this.hammerDBExecutionArguments,
this.HammerDBPackagePath,
telemetryContext,
cancellationToken))
if (string.Equals(this.Action, "PopulateDatabase", StringComparison.OrdinalIgnoreCase))
{
if (!cancellationToken.IsCancellationRequested)
await this.PrepareSQLDatabase(telemetryContext, cancellationToken);
}
else
{
string command = "python3";
string script = $"{this.HammerDBPackagePath}/run-workload.py";

using (IProcessProxy process = await this.ExecuteCommandAsync(
command,
script + " " + this.hammerDBExecutionArguments,
this.HammerDBPackagePath,
telemetryContext,
cancellationToken))
{
await this.LogProcessDetailsAsync(process, telemetryContext, "HammerDB", logToFile: true);
process.ThrowIfErrored<WorkloadException>(process.StandardError.ToString(), ErrorReason.WorkloadFailed);
if (!cancellationToken.IsCancellationRequested)
{
await this.LogProcessDetailsAsync(process, telemetryContext, "HammerDB", logToFile: true);
process.ThrowIfErrored<WorkloadException>(process.StandardError.ToString(), ErrorReason.WorkloadFailed);

this.CaptureMetrics(process, telemetryContext, cancellationToken);
this.CaptureMetrics(process, telemetryContext, cancellationToken);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ public string SQLServer
}
}

/// <summary>
/// The action to perform.
/// </summary>
public string Action
{
get
{
this.Parameters.TryGetValue(nameof(HammerDBClientExecutor.Action), out IConvertible action);
return action?.ToString();
}
}

/// <summary>
/// Client used to communicate with the hosted instance of the
/// Virtual Client API at server side.
Expand Down Expand Up @@ -217,21 +229,25 @@ await this.CheckDistroSupportAsync(cancellationToken)
.ConfigureAwait(false);

await HammerDBExecutor.OpenFirewallPortsAsync(this.Port, this.SystemManager.FirewallManager, cancellationToken);

DependencyPath hammerDBPackage = await this.GetPlatformSpecificPackageAsync(this.PackageName, cancellationToken);
this.HammerDBPackagePath = hammerDBPackage.Path;

await this.InitializeExecutablesAsync(telemetryContext, cancellationToken);


this.InitializeApiClients(cancellationToken);

await this.Logger.LogMessageAsync($"{this.TypeName}.ConfigureHammerDBFile", telemetryContext.Clone(), async () =>
// Only load HammerDB package for x64 executors.
if (this.CpuArchitecture == System.Runtime.InteropServices.Architecture.X64)
{
if (!cancellationToken.IsCancellationRequested)
DependencyPath hammerDBPackage = await this.GetPlatformSpecificPackageAsync(this.PackageName, cancellationToken);
this.HammerDBPackagePath = hammerDBPackage.Path;

await this.InitializeExecutablesAsync(telemetryContext, cancellationToken);

await this.Logger.LogMessageAsync($"{this.TypeName}.ConfigureHammerDBFile", telemetryContext.Clone(), async () =>
{
await this.ConfigureCreateHammerDBFile(telemetryContext, cancellationToken);
}
});
if (!cancellationToken.IsCancellationRequested)
{
await this.ConfigureCreateHammerDBFile(telemetryContext, cancellationToken);
}
});
}

if (this.IsMultiRoleLayout())
{
Expand All @@ -240,7 +256,7 @@ await this.Logger.LogMessageAsync($"{this.TypeName}.ConfigureHammerDBFile", tele

this.ThrowIfLayoutClientIPAddressNotFound(layoutIPAddress);
this.ThrowIfRoleNotSupported(clientInstance.Role);
}
}
}

/// <summary>
Expand Down Expand Up @@ -294,8 +310,11 @@ protected async Task InitializeExecutablesAsync(EventContext telemetryContext, C

await this.stateManager.SaveStateAsync<HammerDBState>(nameof(HammerDBState), state, cancellationToken);
}

private async Task PrepareSQLDatabase(EventContext telemetryContext, CancellationToken cancellationToken)

/// <summary>
/// Prepares the SQL database by executing the createDB TCL script.
/// </summary>
protected async Task PrepareSQLDatabase(EventContext telemetryContext, CancellationToken cancellationToken)
{
string command = "python3";

Expand Down Expand Up @@ -353,7 +372,16 @@ private static Task OpenFirewallPortsAsync(int port, IFirewallManager firewallMa

private async Task CheckDistroSupportAsync(CancellationToken cancellationToken)
{
if (this.CpuArchitecture == System.Runtime.InteropServices.Architecture.X64)
// Check architecture support based on executor type and role
// HammerDBServerExecutor in Server role: Supports both X64 and ARM64 (PostgreSQL server can run on both)
// All other scenarios: Supports only X64 (HammerDB client operations don't support ARM64)
bool isServerExecutorInServerRole = this.IsInRole(ClientRole.Server) && this.GetType() == typeof(HammerDBServerExecutor);
bool isX64 = this.CpuArchitecture == System.Runtime.InteropServices.Architecture.X64;
bool isArm64 = this.CpuArchitecture == System.Runtime.InteropServices.Architecture.Arm64;

bool isArchitectureSupported = isX64 || (isServerExecutorInServerRole && isArm64);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document which distro is supported on which arch in the document.


if (isArchitectureSupported)
{
if (this.Platform == PlatformID.Unix)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,23 @@ public string SharedMemoryBuffer
return sharedMemoryBuffer?.ToString();
}
}

/// <summary>
/// stripedisk mount point.
/// </summary>
public string StripeDiskMountPoint
{
get
{
if (this.Parameters.TryGetValue(nameof(this.StripeDiskMountPoint), out IConvertible stripediskmountpoint) && stripediskmountpoint != null)
{
return stripediskmountpoint.ToString();
}

return string.Empty;
}
}

/// <summary>
/// Retrieves the interface to interacting with the underlying system.
/// </summary>
Expand Down Expand Up @@ -180,9 +196,31 @@ private async Task ConfigurePostgreSQLServerAsync(EventContext telemetryContext,
string serverIp = (this.GetLayoutClientInstances(ClientRole.Server, false) ?? Enumerable.Empty<ClientInstance>())
.FirstOrDefault()?.IPAddress
?? IPAddress.Loopback.ToString();

string arguments = $"{this.packageDirectory}/configure-server.py --dbName {this.DatabaseName} --serverIp {serverIp} --password {this.SuperUserPassword} --port {this.Port} --inMemory {this.SharedMemoryBuffer}";

string innoDbDirs = string.Empty;
if (this.Parameters.ContainsKey(nameof(this.DiskFilter)) || !string.IsNullOrEmpty(this.StripeDiskMountPoint))
{
innoDbDirs = this.Parameters.ContainsKey(nameof(this.DiskFilter)) ? await this.GetPostgreSQLInnodbDirectoriesAsync(cancellationToken) : string.Empty;
innoDbDirs = !string.IsNullOrEmpty(this.StripeDiskMountPoint) ? this.StripeDiskMountPoint : innoDbDirs;

if (!string.IsNullOrEmpty(innoDbDirs))
{
if (innoDbDirs.Split(';', StringSplitOptions.RemoveEmptyEntries).Length == 1)
{
string cleanDirectory = innoDbDirs.TrimEnd(';');
arguments += $" --innodbDirectory {cleanDirectory}";
}
else
{
throw new WorkloadException(
"Multiple InnoDB directories detected. Please specify a single directory for PostgreSQL configuration when using the DiskFilter parameter explicitly for PostgreSQLServerConfiguration.",
ErrorReason.InvalidProfileDefinition);
}
}
}

using (IProcessProxy process = await this.ExecuteCommandAsync(
"python3",
arguments,
Expand Down Expand Up @@ -216,7 +254,7 @@ private async Task SetupPostgreSQLDatabaseAsync(EventContext telemetryContext, C
}
}
}

private async Task DistributePostgreSQLDatabaseAsync(EventContext telemetryContext, CancellationToken cancellationToken)
{
string innoDbDirs = await this.GetPostgreSQLInnodbDirectoriesAsync(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"Parameters": {
"Scenario": "DownloadPostgreSQLPackage",
"BlobContainer": "packages",
"BlobName": "postgresql.14.0.0.rev2.zip",
"BlobName": "postgresql.16.0.0.rev2.zip",
"PackageName": "postgresql",
"Extract": true
}
Expand All @@ -81,7 +81,7 @@
"Parameters": {
"Scenario": "DownloadHammerDBPackage",
"BlobContainer": "packages",
"BlobName": "hammerdb.4.7.0.rev1.zip",
"BlobName": "hammerdb.4.12.0.rev2.zip",
"PackageName": "hammerdb",
"Extract": true
}
Expand Down
Loading