diff --git a/@Installers/Settings/appsettings.json b/@Installers/Settings/appsettings.json index b85cc0be..87390c86 100644 --- a/@Installers/Settings/appsettings.json +++ b/@Installers/Settings/appsettings.json @@ -1,15 +1,15 @@ { "ListenPort": 6858, - "DataRootPath": "C:\\Katzebase\\Root", - "TransactionDataPath": "C:\\Katzebase\\Transaction", - "LogDirectory": "C:\\Katzebase\\Logs", + "DataRootPath": ".\\Data\\Root", + "TransactionDataPath": ".\\Data\\Transaction", + "LogDirectory": ".\\Data\\Logs", "FlushLog": true, "DefaultDocumentPageSize": 100, "HealthMonitoringEnabled": true, "HealthMonitoringCheckpointSeconds": 600, "HealthMonitoringInstanceLevelEnabled": false, "HealthMonitoringInstanceLevelTimeToLiveSeconds": 600, - "MaxIdleConnectionSeconds": 600, + "MaxIdleConnectionSeconds": 30, "DefaultIndexPartitions": 100, "LockWaitTimeoutSeconds": 0, "DeferredIOEnabled": true, diff --git a/@Installers/Setup.Iss b/@Installers/Setup.Iss index 74be7693..f4f1fbc5 100644 --- a/@Installers/Setup.Iss +++ b/@Installers/Setup.Iss @@ -1,7 +1,7 @@ [Setup] ;-- Main Setup Information AppName = Katzebase Server - AppVerName = Katzebase Server 0.26.0 + AppVerName = Katzebase Server 0.27.0 AppCopyright = Copyright © 2024 NetworkDLS. DefaultDirName = {commonpf}\NetworkDLS\Katzebase DefaultGroupName = Katzebase @@ -17,7 +17,7 @@ AppPublisher = NetworkDLS AppPublisherURL = http://www.NetworkDLS.com/ AppUpdatesURL = http://www.NetworkDLS.com/ - AppVersion = 0.26.0 + AppVersion = 0.27.0 [Components] Name: "Server"; Description: "Server"; Types: Full Compact Custom; diff --git a/NTDLS.Katzebase.Api/KbClient.cs b/NTDLS.Katzebase.Api/KbClient.cs index af86f6cf..3be15c85 100644 --- a/NTDLS.Katzebase.Api/KbClient.cs +++ b/NTDLS.Katzebase.Api/KbClient.cs @@ -1,6 +1,7 @@ using NTDLS.Katzebase.Api.Exceptions; using NTDLS.Katzebase.Api.Management; using NTDLS.Katzebase.Api.Models; +using NTDLS.Katzebase.Api.Payloads; using NTDLS.ReliableMessaging; using System.Diagnostics; using System.Security.Cryptography; @@ -20,6 +21,7 @@ public class KbClient : IDisposable public event CommunicationExceptionEvent? OnCommunicationException; private TimeSpan _queryTimeout = TimeSpan.FromSeconds(30); + private Thread? _heartbeatThread; public TimeSpan QueryTimeout { @@ -157,6 +159,9 @@ public void Connect(string hostname, int port, string username, string passwordH ServerConnectionId = reply.ConnectionId; ProcessId = reply.ProcessId; + _heartbeatThread = new Thread(HeartbeatThread); + _heartbeatThread.Start(); + var sessionInfo = new KbSessionInfo { ConnectionId = ServerConnectionId, @@ -172,8 +177,24 @@ public void Connect(string hostname, int port, string username, string passwordH } } + private void HeartbeatThread() + { + var lastCheckInTime = DateTime.UtcNow; + + while (IsConnected) + { + if ((DateTime.UtcNow - lastCheckInTime).TotalSeconds >= KbConstants.HeartbeatSeconds) + { + Connection?.Notify(new KbNotifySessionHeartbeat()); + lastCheckInTime = DateTime.UtcNow; + } + Thread.Sleep(100); + } + } + void Disconnect() { + _heartbeatThread = null; try { try @@ -227,7 +248,6 @@ protected virtual void Dispose(bool disposing) } disposed = true; - } #endregion diff --git a/NTDLS.Katzebase.Api/KbConstants.cs b/NTDLS.Katzebase.Api/KbConstants.cs index d5b4dac7..199d7156 100644 --- a/NTDLS.Katzebase.Api/KbConstants.cs +++ b/NTDLS.Katzebase.Api/KbConstants.cs @@ -3,6 +3,7 @@ public static class KbConstants { public static string FriendlyName = "Katzebase"; + public const int HeartbeatSeconds = 15; public enum KbLogSeverity { diff --git a/NTDLS.Katzebase.Api/NTDLS.Katzebase.Api.csproj b/NTDLS.Katzebase.Api/NTDLS.Katzebase.Api.csproj index 16552b30..e676091d 100644 --- a/NTDLS.Katzebase.Api/NTDLS.Katzebase.Api.csproj +++ b/NTDLS.Katzebase.Api/NTDLS.Katzebase.Api.csproj @@ -7,7 +7,7 @@ enable NetworkDLS Copyright © 2024 NetworkDLS - 0.26.0 + 0.27.0 NetworkDLS Media\IconFull.ico True diff --git a/NTDLS.Katzebase.Api/Payloads/KbQuerySessionHeartbeat.cs b/NTDLS.Katzebase.Api/Payloads/KbQuerySessionHeartbeat.cs new file mode 100644 index 00000000..9fe1e5e9 --- /dev/null +++ b/NTDLS.Katzebase.Api/Payloads/KbQuerySessionHeartbeat.cs @@ -0,0 +1,12 @@ +using NTDLS.Katzebase.Api.Payloads.Response; +using NTDLS.ReliableMessaging; + +namespace NTDLS.Katzebase.Api.Payloads +{ + public class KbNotifySessionHeartbeat : IRmNotification + { + public KbNotifySessionHeartbeat() + { + } + } +} diff --git a/NTDLS.Katzebase.Engine/Interactions/APIHandlers/SessionAPIHandlers.cs b/NTDLS.Katzebase.Engine/Interactions/APIHandlers/SessionAPIHandlers.cs index c2575f44..0d6f5d25 100644 --- a/NTDLS.Katzebase.Engine/Interactions/APIHandlers/SessionAPIHandlers.cs +++ b/NTDLS.Katzebase.Engine/Interactions/APIHandlers/SessionAPIHandlers.cs @@ -124,6 +124,12 @@ public KbQueryServerCloseSessionReply CloseSession(RmContext context, KbQuerySer } } + public void Heartbeat(RmContext context, KbNotifySessionHeartbeat param) + { + //The call to GetSession() will update the LastCheckInTime. + _core.Sessions.GetSession(context.ConnectionId); + } + public KbQueryServerTerminateProcessReply TerminateSession(RmContext context, KbQueryServerTerminateProcess param) { var session = _core.Sessions.GetSession(context.ConnectionId); diff --git a/NTDLS.Katzebase.Engine/Interactions/Management/SessionManager.cs b/NTDLS.Katzebase.Engine/Interactions/Management/SessionManager.cs index 2b90918c..f1bf3819 100644 --- a/NTDLS.Katzebase.Engine/Interactions/Management/SessionManager.cs +++ b/NTDLS.Katzebase.Engine/Interactions/Management/SessionManager.cs @@ -141,24 +141,24 @@ public bool TryCloseByProcessID(ulong processId) // For this reason, we will "try lock" with a timeout, if we fail to remove the session now - it will be // automatically retried by the HeartbeatManager. var wasLockObtained = _collection.TryWrite(100, (obj) => - { - var session = obj.FirstOrDefault(o => o.Value.ProcessId == processId).Value; - if (session != null) { - obj.Remove(session.ConnectionId); - } - }); + var session = obj.FirstOrDefault(o => o.Value.ProcessId == processId).Value; + if (session != null) + { + obj.Remove(session.ConnectionId); + } + }); - if (wasLockObtained == false) + if (wasLockObtained) { - LogManager.Warning($"Lock timeout expired while removing session. The task will be deferred to the heartbeat manager."); + return true; } - - return wasLockObtained; } - else - { - _collection.TryWrite(100, (obj) => + + LogManager.Warning($"Lock timeout expired while removing session. The task will be deferred to the heartbeat manager."); + + //We can TryRead here (instead of TryWrite) because we are not modifying the collection, just a value within it. + _collection.TryRead(100, (obj) => { var session = obj.FirstOrDefault(o => o.Value.ProcessId == processId).Value; if (session != null) @@ -168,7 +168,7 @@ public bool TryCloseByProcessID(ulong processId) session.IsExpired = true; } }); - } + return false; } catch (Exception ex) diff --git a/NTDLS.Katzebase.Engine/Interactions/Management/TransactionManager.cs b/NTDLS.Katzebase.Engine/Interactions/Management/TransactionManager.cs index 3a09b83c..709c63d0 100644 --- a/NTDLS.Katzebase.Engine/Interactions/Management/TransactionManager.cs +++ b/NTDLS.Katzebase.Engine/Interactions/Management/TransactionManager.cs @@ -105,7 +105,6 @@ internal bool TryCloseByProcessID(ulong processId) if (transaction != null) { transaction.Rollback(); - obj.Remove(transaction); } }); diff --git a/NTDLS.Katzebase.Engine/NTDLS.Katzebase.Engine.csproj b/NTDLS.Katzebase.Engine/NTDLS.Katzebase.Engine.csproj index 025ece27..4dc47108 100644 --- a/NTDLS.Katzebase.Engine/NTDLS.Katzebase.Engine.csproj +++ b/NTDLS.Katzebase.Engine/NTDLS.Katzebase.Engine.csproj @@ -7,7 +7,7 @@ enable NetworkDLS Copyright © 2024 NetworkDLS - 0.26.0 + 0.27.0 NetworkDLS Icon.ico diff --git a/NTDLS.Katzebase.Management/NTDLS.Katzebase.Management.csproj b/NTDLS.Katzebase.Management/NTDLS.Katzebase.Management.csproj index 6c16b55b..dfcf43f8 100644 --- a/NTDLS.Katzebase.Management/NTDLS.Katzebase.Management.csproj +++ b/NTDLS.Katzebase.Management/NTDLS.Katzebase.Management.csproj @@ -9,7 +9,7 @@ true NetworkDLS Copyright © 2024 NetworkDLS - 0.26.0 + 0.27.0 NetworkDLS diff --git a/NTDLS.Katzebase.Management/Properties/Resources.Designer.cs b/NTDLS.Katzebase.Management/Properties/Resources.Designer.cs index 21690952..f5834f23 100644 --- a/NTDLS.Katzebase.Management/Properties/Resources.Designer.cs +++ b/NTDLS.Katzebase.Management/Properties/Resources.Designer.cs @@ -103,11 +103,11 @@ internal static System.Drawing.Bitmap GetSQL { /// /// Looks up a localized string similar to <?xml version="1.0"?> ///<SyntaxDefinition name="KBSQL" extensions=".kbs" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008"> - /// <Color name="Punctuation" foreground="Green" exampleText="a(b.c);" /> - /// <Color name="NumberLiteral" foreground="Blue" exampleText="3.1415f"/> - /// <Color name="KbMarkup" foreground="Brown" fontWeight="bold" exampleText="{$INT 10000:30000}" /> - /// <Color name="KbConfig" fontWeight="bold" foreground="DarkCyan" exampleText="TraceWaitTimes"/> - /// <Color name="KbFunction" fontWeig [rest of string was truncated]";. + /// <Color name="Punctuation" foreground="Green" exampleText="a(b.c);" /> + /// <Color name="NumberLiteral" foreground="Blue" exampleText="3.1415f"/> + /// <Color name="KbMarkup" foreground="Brown" fontWeight="bold" exampleText="{$INT 10000:30000}" /> + /// <Color name="KbConfig" fontWeight="bold" foreground="DarkCyan" exampleText="TraceWaitTimes"/> + /// <Color name="KbFunction" fon [rest of string was truncated]";. /// internal static string Highlighter { get { diff --git a/NTDLS.Katzebase.ObjectViewer/NTDLS.Katzebase.ObjectViewer.csproj b/NTDLS.Katzebase.ObjectViewer/NTDLS.Katzebase.ObjectViewer.csproj index d60caa5a..821ffc5d 100644 --- a/NTDLS.Katzebase.ObjectViewer/NTDLS.Katzebase.ObjectViewer.csproj +++ b/NTDLS.Katzebase.ObjectViewer/NTDLS.Katzebase.ObjectViewer.csproj @@ -7,7 +7,7 @@ true enable Icon.ico - 0.26.0 + 0.27.0 diff --git a/NTDLS.Katzebase.Parsers/NTDLS.Katzebase.Parsers.csproj b/NTDLS.Katzebase.Parsers/NTDLS.Katzebase.Parsers.csproj index 1bba9fcc..6bf44b68 100644 --- a/NTDLS.Katzebase.Parsers/NTDLS.Katzebase.Parsers.csproj +++ b/NTDLS.Katzebase.Parsers/NTDLS.Katzebase.Parsers.csproj @@ -6,7 +6,7 @@ enable NetworkDLS Copyright © 2024 NetworkDLS - 0.26.0 + 0.27.0 NetworkDLS diff --git a/NTDLS.Katzebase.PersistentTypes/NTDLS.Katzebase.PersistentTypes.csproj b/NTDLS.Katzebase.PersistentTypes/NTDLS.Katzebase.PersistentTypes.csproj index 56772375..693cd81b 100644 --- a/NTDLS.Katzebase.PersistentTypes/NTDLS.Katzebase.PersistentTypes.csproj +++ b/NTDLS.Katzebase.PersistentTypes/NTDLS.Katzebase.PersistentTypes.csproj @@ -6,7 +6,7 @@ enable NetworkDLS Copyright © 2024 NetworkDLS - 0.26.0 + 0.27.0 NetworkDLS diff --git a/NTDLS.Katzebase.SQLServerMigration/Forms/FormMain.cs b/NTDLS.Katzebase.SQLServerMigration/Forms/FormMain.cs index c9830fad..f892e5a1 100644 --- a/NTDLS.Katzebase.SQLServerMigration/Forms/FormMain.cs +++ b/NTDLS.Katzebase.SQLServerMigration/Forms/FormMain.cs @@ -482,6 +482,11 @@ private void ExportSQLServerTableToKatzebase(SelectedImportObject item, string t #endregion + if (_isCancelPending) + { + return; + } + #region Import Inexes. if (item.ImportIndexes) @@ -493,6 +498,11 @@ private void ExportSQLServerTableToKatzebase(SelectedImportObject item, string t foreach (var sourceIndex in sourceIndexes) { + if (_isCancelPending) + { + return; + } + if (client.Schema.Indexes.Exists(item.TargetServerSchema, sourceIndex.Key.EnsureNotNull()) == false) { var targetIndex = new KbIndex(sourceIndex.Key.EnsureNotNull()) diff --git a/NTDLS.Katzebase.SQLServerMigration/NTDLS.Katzebase.SQLServerMigration.csproj b/NTDLS.Katzebase.SQLServerMigration/NTDLS.Katzebase.SQLServerMigration.csproj index 2dde5a31..c0620773 100644 --- a/NTDLS.Katzebase.SQLServerMigration/NTDLS.Katzebase.SQLServerMigration.csproj +++ b/NTDLS.Katzebase.SQLServerMigration/NTDLS.Katzebase.SQLServerMigration.csproj @@ -8,7 +8,7 @@ enable NetworkDLS Copyright © 2024 NetworkDLS - 0.26.0 + 0.27.0 NetworkDLS Icon.ico NTDLS.Katzebase.SQLServerMigration.Program diff --git a/NTDLS.Katzebase.SQLServerMigration/Properties/Resources.Designer.cs b/NTDLS.Katzebase.SQLServerMigration/Properties/Resources.Designer.cs index 9dab0cae..f86e21f2 100644 --- a/NTDLS.Katzebase.SQLServerMigration/Properties/Resources.Designer.cs +++ b/NTDLS.Katzebase.SQLServerMigration/Properties/Resources.Designer.cs @@ -82,8 +82,7 @@ internal static System.Drawing.Bitmap Login { /// INNER JOIN sys.tables t ON i.object_id = t.object_id ///WHERE /// i.is_disabled = 0 -- Exclude disabled indexes - /// AND ic.is_included_column = 0 - /// AND '[' + [rest of string was truncated]";. + /// AND ic.is_included_column = 0 [rest of string was truncated]";. /// internal static string SqlGetObjectIndexes { get { @@ -99,7 +98,7 @@ internal static string SqlGetObjectIndexes { /// ISNULL(SUM(p.reserved_page_count) * 8 * 1024, 0) AS TotalSizeBytes, -- Total size in bytes /// ISNULL(SUM(p.row_count), 0) AS TotalRows, -- Total rows /// CASE - /// WHEN SUM(p.row_count) > 0 THEN (SUM(p.reserved_page_count) * 8 * 1024) / SUM(p.row [rest of string was truncated]";. + /// WHEN SUM(p.row_count) > 0 THEN (SUM(p.reserved_page_count) * 8 * 1024) / SU [rest of string was truncated]";. /// internal static string SqlGetObjectsAndSizes { get { diff --git a/NTDLS.Katzebase.Server/NTDLS.Katzebase.Server.csproj b/NTDLS.Katzebase.Server/NTDLS.Katzebase.Server.csproj index ef53cad1..98876aea 100644 --- a/NTDLS.Katzebase.Server/NTDLS.Katzebase.Server.csproj +++ b/NTDLS.Katzebase.Server/NTDLS.Katzebase.Server.csproj @@ -6,7 +6,7 @@ enable NetworkDLS Copyright © 2024 NetworkDLS - 0.26.0 + 0.27.0 NetworkDLS Icon.ico Exe diff --git a/NTDLS.Katzebase.Server/appsettings.json b/NTDLS.Katzebase.Server/appsettings.json index bfb22bd7..7659cb4b 100644 --- a/NTDLS.Katzebase.Server/appsettings.json +++ b/NTDLS.Katzebase.Server/appsettings.json @@ -9,7 +9,7 @@ "HealthMonitoringCheckpointSeconds": 600, "HealthMonitoringInstanceLevelEnabled": false, "HealthMonitoringInstanceLevelTimeToLiveSeconds": 600, - "MaxIdleConnectionSeconds": 60, + "MaxIdleConnectionSeconds": 30, "DefaultIndexPartitions": 100, "LockWaitTimeoutSeconds": 0, "DeferredIOEnabled": true, diff --git a/NTDLS.Katzebase.Shared/NTDLS.Katzebase.Shared.csproj b/NTDLS.Katzebase.Shared/NTDLS.Katzebase.Shared.csproj index e91ab9d8..76b7f71c 100644 --- a/NTDLS.Katzebase.Shared/NTDLS.Katzebase.Shared.csproj +++ b/NTDLS.Katzebase.Shared/NTDLS.Katzebase.Shared.csproj @@ -7,7 +7,7 @@ enable NetworkDLS Copyright © 2024 NetworkDLS - 0.26.0 + 0.27.0 NetworkDLS