Implement DEFAULT_ISOLATION_LEVEL setting#173
Conversation
There was a problem hiding this comment.
Hello @apstndb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request implements the DEFAULT_ISOLATION_LEVEL system variable/property. This allows users to configure the default transaction isolation level for read-write transactions. The changes include adding the new variable to the systemVariables struct, updating the README.md file to document the new variable, and adding a test case to verify that the isolation level is correctly applied when beginning a read-write transaction.
Highlights
- New Feature: Implements the
DEFAULT_ISOLATION_LEVELsystem variable/property. - Configuration: Adds the
DefautIsolationLevelfield to thesystemVariablesstruct insystem_variables.go. - Documentation: Updates
README.mdto include documentation for the newDEFAULT_ISOLATION_LEVELvariable. - Testing: Adds a new test case
TestIsolationLevelinsession_slow_test.goto verify the functionality.
Changelog
Click here to see the changelog
- README.md
- Added
DEFAULT_ISOLATION_LEVELto the table of system variables with a default value ofREPEATABLE_READ.
- Added
- session.go
- Modified
BeginReadWriteTransactionto include theIsolationLevelfromsystemVariableswhen creating a new read-write transaction.
- Modified
- session_slow_test.go
- Added
TestIsolationLevelto verify that the default isolation level is correctly applied to read-write transactions. - Uses spanemuboost to setup an emulator for testing.
- Records gRPC requests to verify the transaction options.
- Added
- system_variables.go
- Added
DefautIsolationLevelfield to thesystemVariablesstruct to store the default isolation level. - Added a new entry for
DEFAULT_ISOLATION_LEVELinsystemVariableDefMapto define its description, setter, and getter.
- Added
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A new setting takes its place,
Isolation level, set with grace.
Repeatable read or serial,
The database knows what's real.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This PR introduces the DEFAULT_ISOLATION_LEVEL system variable, enhancing the configurability of transaction isolation levels. The changes seem well-structured and include a test case to verify the functionality. However, there are a few areas that could benefit from further attention.
Summary of Findings
- Missing Error Handling: The
Setterfunction forDEFAULT_ISOLATION_LEVELinsystem_variables.godoes not handle the case where the provided value does not match any of the validsppb.TransactionOptions_IsolationLevelvalues. This could lead to unexpected behavior if an invalid value is set. - Inconsistent Naming: The variable name
DefautIsolationLevelinsession.goandsystem_variables.gohas a typo. It should beDefaultIsolationLevelfor consistency and readability.
Merge Readiness
While the changes are a valuable addition, addressing the error handling and naming inconsistency would improve the robustness and maintainability of the code. I recommend addressing these issues before merging. I am unable to directly approve this pull request, and other reviewers should also review this code before merging.
| this.DefautIsolationLevel = sppb.TransactionOptions_IsolationLevel(isolation) | ||
| } | ||
| return nil |
There was a problem hiding this comment.
This setter doesn't handle the case where the value string doesn't match any of the enum values in sppb.TransactionOptions_IsolationLevel_value. Consider adding a default case or returning an error to handle invalid input.
if ok {
this.DefaultIsolationLevel = sppb.TransactionOptions_IsolationLevel(isolation)
} else {
return fmt.Errorf("invalid isolation level: %s", value)
}| CommitPriority: priority, | ||
| TransactionTag: tag, | ||
| ExcludeTxnFromChangeStreams: s.systemVariables.ExcludeTxnFromChangeStreams, | ||
| IsolationLevel: s.systemVariables.DefautIsolationLevel, |
There was a problem hiding this comment.
| MaxPartitionedParallelism int64 // MAX_PARTITIONED_PARALLELISM | ||
| AutocommitDMLMode AutocommitDMLMode // AUTOCOMMIT_DML_MODE | ||
|
|
||
| DefautIsolationLevel sppb.TransactionOptions_IsolationLevel // DEFAULT_ISOLATION_LEVEL |
There was a problem hiding this comment.
The variable name DefautIsolationLevel has a typo. Consider renaming it to DefaultIsolationLevel for consistency and readability.
| DefautIsolationLevel sppb.TransactionOptions_IsolationLevel // DEFAULT_ISOLATION_LEVEL | |
| DefaultIsolationLevel sppb.TransactionOptions_IsolationLevel // DEFAULT_ISOLATION_LEVEL |
This PR implements
DEFAULT_ISOLATION_LEVELsystem variable/property.Reference