Skip to content

Implement DEFAULT_ISOLATION_LEVEL setting#173

Merged
apstndb merged 9 commits intomainfrom
feature/default-transaction-isolation
Mar 24, 2025
Merged

Implement DEFAULT_ISOLATION_LEVEL setting#173
apstndb merged 9 commits intomainfrom
feature/default-transaction-isolation

Conversation

@apstndb
Copy link
Copy Markdown
Owner

@apstndb apstndb commented Mar 24, 2025

This PR implements DEFAULT_ISOLATION_LEVEL system variable/property.

Reference

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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_LEVEL system variable/property.
  • Configuration: Adds the DefautIsolationLevel field to the systemVariables struct in system_variables.go.
  • Documentation: Updates README.md to include documentation for the new DEFAULT_ISOLATION_LEVEL variable.
  • Testing: Adds a new test case TestIsolationLevel in session_slow_test.go to verify the functionality.

Changelog

Click here to see the changelog
  • README.md
    • Added DEFAULT_ISOLATION_LEVEL to the table of system variables with a default value of REPEATABLE_READ.
  • session.go
    • Modified BeginReadWriteTransaction to include the IsolationLevel from systemVariables when creating a new read-write transaction.
  • session_slow_test.go
    • Added TestIsolationLevel to 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.
  • system_variables.go
    • Added DefautIsolationLevel field to the systemVariables struct to store the default isolation level.
    • Added a new entry for DEFAULT_ISOLATION_LEVEL in systemVariableDefMap to define its description, setter, and getter.
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

  1. 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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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 Setter function for DEFAULT_ISOLATION_LEVEL in system_variables.go does not handle the case where the provided value does not match any of the valid sppb.TransactionOptions_IsolationLevel values. This could lead to unexpected behavior if an invalid value is set.
  • Inconsistent Naming: The variable name DefautIsolationLevel in session.go and system_variables.go has a typo. It should be DefaultIsolationLevel for 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.

Comment thread system_variables.go Outdated
Comment on lines +227 to +229
this.DefautIsolationLevel = sppb.TransactionOptions_IsolationLevel(isolation)
}
return nil
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.

high

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)
				}

Comment thread session.go Outdated
CommitPriority: priority,
TransactionTag: tag,
ExcludeTxnFromChangeStreams: s.systemVariables.ExcludeTxnFromChangeStreams,
IsolationLevel: s.systemVariables.DefautIsolationLevel,
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.

medium

The variable name DefautIsolationLevel has a typo. Consider renaming it to DefaultIsolationLevel for consistency and readability.

Suggested change
IsolationLevel: s.systemVariables.DefautIsolationLevel,
IsolationLevel: s.systemVariables.DefaultIsolationLevel,

Comment thread system_variables.go Outdated
MaxPartitionedParallelism int64 // MAX_PARTITIONED_PARALLELISM
AutocommitDMLMode AutocommitDMLMode // AUTOCOMMIT_DML_MODE

DefautIsolationLevel sppb.TransactionOptions_IsolationLevel // DEFAULT_ISOLATION_LEVEL
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.

medium

The variable name DefautIsolationLevel has a typo. Consider renaming it to DefaultIsolationLevel for consistency and readability.

Suggested change
DefautIsolationLevel sppb.TransactionOptions_IsolationLevel // DEFAULT_ISOLATION_LEVEL
DefaultIsolationLevel sppb.TransactionOptions_IsolationLevel // DEFAULT_ISOLATION_LEVEL

@apstndb apstndb merged commit bd9ee49 into main Mar 24, 2025
2 checks passed
@apstndb apstndb deleted the feature/default-transaction-isolation branch March 24, 2025 09:16
@apstndb apstndb restored the feature/default-transaction-isolation branch March 24, 2025 09:57
@apstndb apstndb added the enhancement New feature or request label Mar 24, 2025
@apstndb apstndb deleted the feature/default-transaction-isolation branch March 24, 2025 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant