@@ -52,8 +52,8 @@ class RevokableQuotaLimiter(QuotaLimiter):
5252 # Reconciliation SQL for user quotas - updates all user rows
5353 RECONCILE_USER_QUOTA_LIMITS = """
5454 UPDATE quota_limits
55- SET quota_limit = %s ,
56- available = available + (%s - quota_limit) ,
55+ SET available = available + (%s - quota_limit) ,
56+ quota_limit = %s ,
5757 updated_at = NOW()
5858 WHERE subject = 'u'
5959 AND quota_limit != %s
@@ -63,8 +63,8 @@ class RevokableQuotaLimiter(QuotaLimiter):
6363 # Reconciliation SQL for cluster quotas - updates cluster row
6464 RECONCILE_CLUSTER_QUOTA_LIMITS = """
6565 UPDATE quota_limits
66- SET quota_limit = %s ,
67- available = available + (%s - quota_limit) ,
66+ SET available = available + (%s - quota_limit) ,
67+ quota_limit = %s ,
6868 updated_at = NOW()
6969 WHERE subject = 'c'
7070 AND quota_limit != %s
@@ -84,20 +84,18 @@ def __init__(
8484 self .increase_by = increase_by
8585 self .connection_config = connection_config
8686
87- def connect (self ) -> None :
88- """Initialize connection to database and reconcile quota limits .
87+ def reconcile_quota_limits (self ) -> None :
88+ """Reconcile quota limits with current configuration .
8989
90- Reconciliation ensures database quota limits match OLSConfig after updates .
91- This happens on first request after config changes, ensuring immediate sync.
92- The quota_scheduler also runs reconciliation periodically as a backup .
90+ Public method to trigger reconciliation after initialization .
91+ Should be called after quota limiters are created to ensure
92+ database quota limits match OLSConfig after updates .
9393 """
94- super ().connect ()
95- # Reconcile on connect so changes take effect on first request after OLSConfig update
9694 try :
9795 self ._reconcile_quota_limits ()
9896 except Exception as e :
9997 logger .warning (
100- "Quota reconciliation on connect failed (will retry on scheduler): %s" , e
98+ "Quota reconciliation failed (will retry on scheduler): %s" , e
10199 )
102100
103101 @connection
@@ -232,8 +230,8 @@ def _reconcile_quota_limits(self) -> None:
232230 cursor .execute (
233231 reconcile_sql ,
234232 (
235- self .initial_quota , # new quota_limit
236233 self .initial_quota , # used in calculation: available + (new - old)
234+ self .initial_quota , # new quota_limit to set
237235 self .initial_quota , # WHERE quota_limit != ?
238236 ),
239237 )
0 commit comments