From d1036598a1873f933aeb735111ddb04793984850 Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Tue, 24 Mar 2026 16:08:32 -0400 Subject: [PATCH] Include DatabaseName in storage key for Azure SQL DB connections (#677) GetServerNameForStorage() only used ServerName for hashing, so two Azure SQL DB connections on the same logical server with different databases got the same server_id. Database-scoped DMVs like dm_db_resource_stats then had their data interleaved. Now appends "/DatabaseName" to the storage key when DatabaseName is set, giving each database its own server_id and clean data separation. Co-Authored-By: Claude Opus 4.6 (1M context) --- Lite/Services/RemoteCollectorService.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Lite/Services/RemoteCollectorService.cs b/Lite/Services/RemoteCollectorService.cs index e8f51c9..d22978b 100644 --- a/Lite/Services/RemoteCollectorService.cs +++ b/Lite/Services/RemoteCollectorService.cs @@ -682,12 +682,22 @@ protected static long GenerateCollectionId() /// /// Gets the server name used for DuckDB storage and hashing. + /// Appends "/DatabaseName" when set so Azure SQL DB connections to different + /// databases on the same logical server get distinct server_ids (#677). /// Appends ":RO" for ReadOnlyIntent connections so they get a /// different server_id than read-write connections to the same host. /// internal static string GetServerNameForStorage(ServerConnection server) { - return server.ReadOnlyIntent ? server.ServerName + ":RO" : server.ServerName; + var name = server.ServerName; + + if (!string.IsNullOrWhiteSpace(server.DatabaseName)) + name += "/" + server.DatabaseName; + + if (server.ReadOnlyIntent) + name += ":RO"; + + return name; } ///