Skip to content

RG-T117 Fixes for Redis and Chatbot#431

Merged
ucswift merged 1 commit into
masterfrom
develop
Jul 18, 2026
Merged

RG-T117 Fixes for Redis and Chatbot#431
ucswift merged 1 commit into
masterfrom
develop

Conversation

@ucswift

@ucswift ucswift commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Chatbot queries such as “current status” and “current staffing” are now recognized.
  • Bug Fixes
    • Health monitoring now reports Service Bus connectivity accurately.
    • Health checks are more reliable when cache connectivity is unavailable.
    • Improved health endpoint stability by preventing unnecessary session processing.

@request-info

request-info Bot commented Jul 18, 2026

Copy link
Copy Markdown

Thanks for opening this, but we'd appreciate a little more information. Could you update it with more details?

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The changes expand chatbot status matching, make Redis connectivity checks null-safe, alter Redis reconnection behavior, report service-bus health correctly, and bypass session middleware for the current-health endpoint.

Changes

Chatbot intent matching

Layer / File(s) Summary
Status query pattern updates
Core/Resgrid.Chatbot.NLU/Providers/KeywordIntentClassifier.cs
Status and staffing queries now accept an optional current prefix while routing to my_status.

Connectivity and health handling

Layer / File(s) Summary
Redis connection and health endpoint behavior
Providers/Resgrid.Providers.Cache/AzureRedisCacheProvider.cs, Web/Resgrid.Web/Controllers/HealthController.cs, Web/Resgrid.Web/Startup.cs
Redis connectivity now handles null connections and retries only when the connection is null. The health response reports service-bus connectivity, and session middleware excludes /health/getcurrent.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: github-actions

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main changes, covering Redis-related fixes and chatbot intent updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch develop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Providers/Resgrid.Providers.Cache/AzureRedisCacheProvider.cs (1)

291-323: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Race condition during static connection initialization.

_connection is a static field, but EstablishRedisConnection() initializes it without thread synchronization. If multiple instances of AzureRedisCacheProvider are constructed concurrently while _connection is null, they will all run this method simultaneously and create new ConnectionMultiplexer instances. The later instances will overwrite _connection, leaking the previously created multiplexers (and their background threads/sockets).

Please synchronize the initialization using a static lock. Note that to use the fix below, you will also need to add private static readonly object _connectionLock = new object(); at the class level.

🔒️ Proposed fix with lock
-		private void EstablishRedisConnection()
-		{
-			int retry = 0;
-
-			while (_connection == null && retry <= 3)
-			{
-				retry++;
-
-				try
-				{
-					var options = ConfigurationOptions.Parse(Config.CacheConfig.RedisConnectionString);
-					options.AbortOnConnectFail = false;
-					options.ConnectRetry = 1;
-					options.ConnectTimeout = Math.Min(options.ConnectTimeout, 1000);
-					options.SyncTimeout = 1000;
-					options.AsyncTimeout = 1000;
-
-					_connection = ConnectionMultiplexer.Connect(options);
-				}
-				catch (Exception ex)
-				{
-					_connection = null;
-					Logging.LogException(ex);
-					Thread.Sleep(150);
-				}
-			}
-		}
+		private void EstablishRedisConnection()
+		{
+			if (_connection != null)
+				return;
+
+			lock (_connectionLock)
+			{
+				int retry = 0;
+
+				while (_connection == null && retry <= 3)
+				{
+					retry++;
+
+					try
+					{
+						var options = ConfigurationOptions.Parse(Config.CacheConfig.RedisConnectionString);
+						options.AbortOnConnectFail = false;
+						options.ConnectRetry = 1;
+						options.ConnectTimeout = Math.Min(options.ConnectTimeout, 1000);
+						options.SyncTimeout = 1000;
+						options.AsyncTimeout = 1000;
+
+						_connection = ConnectionMultiplexer.Connect(options);
+					}
+					catch (Exception ex)
+					{
+						_connection = null;
+						Logging.LogException(ex);
+						Thread.Sleep(150);
+					}
+				}
+			}
+		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Providers/Resgrid.Providers.Cache/AzureRedisCacheProvider.cs` around lines
291 - 323, Synchronize static connection initialization in
EstablishRedisConnection by adding a class-level private static readonly
_connectionLock object and locking the entire null-check/retry initialization
flow. Recheck _connection inside the lock before calling
ConnectionMultiplexer.Connect so concurrent AzureRedisCacheProvider
constructions reuse the single established connection and do not overwrite it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@Providers/Resgrid.Providers.Cache/AzureRedisCacheProvider.cs`:
- Around line 291-323: Synchronize static connection initialization in
EstablishRedisConnection by adding a class-level private static readonly
_connectionLock object and locking the entire null-check/retry initialization
flow. Recheck _connection inside the lock before calling
ConnectionMultiplexer.Connect so concurrent AzureRedisCacheProvider
constructions reuse the single established connection and do not overwrite it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 66708b5a-ae1f-4157-89d6-d8ddde63c8ed

📥 Commits

Reviewing files that changed from the base of the PR and between e21da36 and 9910d22.

⛔ Files ignored due to path filters (1)
  • Tests/Resgrid.Tests/Chatbot/ChatbotAvailabilityIntentClassifierTests.cs is excluded by !**/Tests/**
📒 Files selected for processing (4)
  • Core/Resgrid.Chatbot.NLU/Providers/KeywordIntentClassifier.cs
  • Providers/Resgrid.Providers.Cache/AzureRedisCacheProvider.cs
  • Web/Resgrid.Web/Controllers/HealthController.cs
  • Web/Resgrid.Web/Startup.cs

@ucswift

ucswift commented Jul 18, 2026

Copy link
Copy Markdown
Member Author

Approve

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR is approved.

@ucswift
ucswift merged commit 0fe1649 into master Jul 18, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant