You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* check the changes and set worker to 1 if tables are absent.
* add comments
* get chnages query
* log error
* check for error number
* update exception check
* add test
* undo test
* throw exception
* update log message
* comments
* add test
* detailed comments
* fix compiler error
* BracketQuotedFullName
// Instance concurrency value is set by the functions host when dynamic concurrency is enabled. See https://learn.microsoft.com/en-us/azure/azure-functions/functions-concurrency for more details.
// Instance concurrency value is set by the functions host when dynamic concurrency is enabled. See https://learn.microsoft.com/en-us/azure/azure-functions/functions-concurrency for more details.
// If the exception is SQL exception and indicates that the object name is invalid, it means that the global state and leases table are not created
52
+
// Check for the error number 208 https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-208-database-engine-error?view=sql-server-ver17
53
+
if(exisSqlExceptionsqlEx&&sqlEx.Number==208)
54
+
{
55
+
// If it's been 2 minutes since we first spun up the worker and the table still isn't created then stop trying
56
+
// since it likely means something else is wrong we can't fix automatically, and we don't want to leave an
57
+
// instance running forever.
58
+
this._logger.LogWarning("Invalid object name detected. SQL trigger tables not found.");
this._logger.LogWarning("Returning 0 as the target worker count since the GetMetrics query threw an 'Invalid object name detected' error and we've exceeded the warmup period for scaling up a new instance to create the required state tables.");
62
+
returnnewTargetScalerResult
63
+
{
64
+
TargetWorkerCount=0
65
+
};
66
+
}
67
+
else
68
+
{
69
+
// Check if there are any changes in the user table. Since we don't have a leases table that means
70
+
// we haven't processed any of the changes yet so we can just check if there's any changes
// If there are changes in the user table, we spin up worker(s) to start handling those changes.
74
+
// This will also create the global state and leases table, which will allow the scaling logic to start working as intended.
75
+
if(changes>0)
76
+
{
77
+
this._logger.LogWarning("There are changes in the change-tracking table for the user table, but the global state and leases table are not created. Spinning up worker instances to create those tables and start processing changes.");
0 commit comments