Fix invalid AuthMech crashing with Recursive update / StackOverflowError#1558
Open
sreekanth-db wants to merge 1 commit into
Open
Fix invalid AuthMech crashing with Recursive update / StackOverflowError#1558sreekanth-db wants to merge 1 commit into
sreekanth-db wants to merge 1 commit into
Conversation
Connecting with an unsupported AuthMech (e.g. AuthMech=99) intermittently crashed with an internal IllegalStateException: Recursive update or a StackOverflowError on both SEA and Thrift, instead of a clean validation error. The value was detected deep inside ClientConfigurator construction, which runs inside getConfigurator's ConcurrentHashMap.computeIfAbsent; the failure fired a telemetry log whose feature-flag refresh re-entered getConfigurator for the same connectionUuid, causing a reentrant computeIfAbsent. Validate AuthMech at connect time (DatabricksConnectionContext.parse -> ValidationUtil.validateInputProperties) before the configurator machinery runs, rejecting unsupported values deterministically with a DatabricksValidationException (SQLState=INPUT_VALIDATION_ERROR). A pure AuthMech.fromValue lookup is the single source of truth for supported values. Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AuthMech(e.g.AuthMech=99) intermittently failed with an internalIllegalStateException: Recursive updateor aStackOverflowErroron both the SEA and Thrift paths, instead of a clean validation error.AuthMech.parseAuthMechthrows duringClientConfiguratorconstruction, which runs insideDatabricksClientConfiguratorManager.getConfigurator'sConcurrentHashMap.computeIfAbsent. The exception's constructor emits a telemetry failure log, whose feature-flag refresh re-entersgetConfiguratorfor the sameconnectionUuid→ a reentrantcomputeIfAbsent→Recursive update(or, depending on timing,StackOverflowError).AuthMechat connect time inDatabricksConnectionContext.parse()(viaValidationUtil.validateInputProperties→ newvalidateAuthMech), before the configurator machinery runs. Unsupported values are now rejected deterministically with aDatabricksValidationException(SQLState=INPUT_VALIDATION_ERROR).AuthMech.fromValue(int)lookup is introduced as the single source of truth for supported values (3=PAT,11=OAuth);parseAuthMechdelegates to it, so adding a new AuthMech is a one-line change.parseAuthMech's behavior, exception type, and messages are unchanged.Test plan
ValidationUtilTest#testValidateAuthMech_*: supported values (3,11, omitted) pass; unsupported/non-integer/empty throwINPUT_VALIDATION_ERROR.DatabricksConnectionContextTest#parse_rejectsUnsupportedAuthMech_withInputValidationError.AuthFlowParsingand fullValidationUtilTest(47) /DatabricksConnectionContextTest(145) suites pass.AuthMech=99went fromIllegalStateException: Recursive update(5/5 attempts on both SEA and Thrift) to a cleanDatabricksValidationException/INPUT_VALIDATION_ERROR(5/5 on both transports).