Skip to content

Add a DB based session property manager#24995

Merged
tdcmeehan merged 2 commits into
prestodb:masterfrom
infvg:db-session-property
Sep 3, 2025
Merged

Add a DB based session property manager#24995
tdcmeehan merged 2 commits into
prestodb:masterfrom
infvg:db-session-property

Conversation

@infvg

@infvg infvg commented Apr 28, 2025

Copy link
Copy Markdown
Contributor

Description

Add a DB based session property manager.

Motivation and Context

Will add the option of adding a new session property manager

Impact

A new db-based session property manager. Will be off by default but can be turned on using the config session-property-config.configuration-manager=db

Test Plan

Unit tests

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

== RELEASE NOTES ==

General Changes
* Added a new db-based session property manager. :doc:`/admin/session-property-managers`

@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Apr 28, 2025
@infvg infvg force-pushed the db-session-property branch from b9191b4 to a405418 Compare April 28, 2025 11:37
@infvg infvg force-pushed the db-session-property branch 2 times, most recently from 064f35e to 9f7283f Compare May 25, 2025 08:30
@infvg infvg marked this pull request as ready for review May 25, 2025 10:25
@infvg infvg requested review from a team and shrinidhijoshi as code owners May 25, 2025 10:25
@infvg infvg requested a review from hantangwangd May 25, 2025 10:25
@prestodb-ci prestodb-ci requested review from a team, ShahimSharafudeen and wanglinsong and removed request for a team May 25, 2025 10:25
@infvg infvg force-pushed the db-session-property branch 2 times, most recently from c335922 to b29057b Compare May 26, 2025 09:01

@pratyakshsharma pratyakshsharma left a comment

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.

Thank you for raising this PR @infvg. One high level comment - please update the docs section for "Session Property Managers" with file and db based managers that will be supported post this change.
I am still going over the changes.

@infvg infvg force-pushed the db-session-property branch 2 times, most recently from f174a51 to fd53f8b Compare June 18, 2025 09:05

@steveburnett steveburnett left a comment

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.

Thanks for the documentation! A few suggestions.

Comment thread presto-docs/src/main/sphinx/admin/session-property-managers.rst Outdated
Comment thread presto-docs/src/main/sphinx/admin/session-property-managers.rst Outdated
Comment thread presto-docs/src/main/sphinx/admin/session-property-managers.rst Outdated
Comment thread presto-docs/src/main/sphinx/admin/session-property-managers.rst Outdated
Comment thread presto-docs/src/main/sphinx/admin/session-property-managers.rst
@infvg infvg force-pushed the db-session-property branch 3 times, most recently from 78ac74c to 30a553c Compare June 23, 2025 08:01

@steveburnett steveburnett left a comment

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.

Minor phrasing suggestion.

Comment thread presto-docs/src/main/sphinx/admin/session-property-managers.rst Outdated
@infvg infvg force-pushed the db-session-property branch from 30a553c to 4c6495f Compare June 25, 2025 06:07
steveburnett
steveburnett previously approved these changes Jun 25, 2025

@steveburnett steveburnett left a comment

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.

LGTM! (docs)

Pull updated branch, new local doc build, looks good. Thanks!

@infvg infvg requested a review from imjalpreet July 11, 2025 14:12

@imjalpreet imjalpreet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@infvg, thank you, I finished my first pass, please have a look.

Comment on lines +34 to +37
session-property-manager.db.url=url
session-property-manager.db.username=username
session-property-manager.db.password=password
session-property-manager.db.refresh-period=50s

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is missing one config. Please add session-property-config.configuration-manager=db as that is required to enable the DB-based session property manager.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@infvg I think we should also add a brief description of every new property introduced. @steveburnett, do you think that would be useful?

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.

@imjalpreet yes, I agree. All properties should be documented. See Designing Your Code section iii in CONTRIBUTING.md.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added an explanation for session-property-manager.db.url and session-property-manager.db.refresh-period. I also added the session-property-config.configuration-manager=db


.. code-block:: text

presto:tpch> DESCRIBE session_specs;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This table is present in the MySQL DB. The CLI prompt presto:tpch> is a little confusing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should show output from MySQL CLI rather than Presto CLI.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed


.. code-block:: text

presto:tpch> DESCRIBE session_client_tags;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This table is present in the MySQL DB. The CLI prompt presto:tpch> is a little confusing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed


.. code-block:: text

presto:tpch> DESCRIBE session_property_values;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This table is present in the MySQL DB. The CLI prompt presto:tpch> is a little confusing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed

session-property-manager.db.password=password
session-property-manager.db.refresh-period=50s

This database consists of three tables: session specs, client tags and properties.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should also note in the documentation that these tables will be automatically created in the configured database on the first server startup after the configurations are added, if they do not already exist.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a note

import static com.facebook.presto.session.file.FileSessionPropertyManager.CODEC;
import static org.testng.Assert.assertEquals;

public class TestFileSessionPropertyManager

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we add a similar test for the DB-based session property manager?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added tests

return resourceGroupManager;
}

public SessionPropertyDefaults getSessionPropertyDefaults()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need the changes in this file? I don't see any usage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed

Comment on lines +157 to +176
<dependency>
<groupId>io.airlift</groupId>
<artifactId>testing-mysql-server</artifactId>
<version>8.0.12-2</version>
<exclusions>
<exclusion>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't see any tests added yet that are using this dependency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to similar mysql dependencies that are used in the new tests.

Comment on lines +46 to +47
@Override
public SystemSessionPropertyConfiguration getSystemSessionProperties(SessionConfigurationContext context)
{
List<SessionMatchSpec> sessionMatchSpecs = specsProvider.get();

// later properties override earlier properties
Map<String, String> defaultProperties = new HashMap<>();
Set<String> overridePropertyNames = new HashSet<String>();
for (SessionMatchSpec sessionMatchSpec : sessionMatchSpecs) {
Map<String, String> newProperties = sessionMatchSpec.match(context);
defaultProperties.putAll(newProperties);
if (sessionMatchSpec.getOverrideSessionProperties().orElse(false)) {
overridePropertyNames.addAll(newProperties.keySet());
}
}

// Once a property has been overridden it stays that way and the value is updated by any rule
Map<String, String> overrideProperties = new HashMap<>();
for (String propertyName : overridePropertyNames) {
overrideProperties.put(propertyName, defaultProperties.get(propertyName));
}

return new SystemSessionPropertyConfiguration(ImmutableMap.copyOf(defaultProperties), ImmutableMap.copyOf(overrideProperties));
}

@Override
public Map<String, Map<String, String>> getCatalogSessionProperties(SessionConfigurationContext context)
{
// NOT IMPLEMENTED YET
return ImmutableMap.of();
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't override these. Based on what I understand, we can just override the abstract method: getSessionMatchSpecs in all implementations of AbstractSessionPropertyManager

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@imjalpreet imjalpreet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@infvg, please rebase on the latest master as well to trigger all tests.

@infvg infvg force-pushed the db-session-property branch 2 times, most recently from 27e542f to f1c7154 Compare August 25, 2025 19:00
@aaneja aaneja self-requested a review August 26, 2025 07:52
aaneja
aaneja previously approved these changes Aug 26, 2025

@imjalpreet imjalpreet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@infvg, thank you! Mostly LGTM, just a couple of suggestions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It might be useful for Presto users if we add a note in this doc that it is recommended to use DB-based session property managers in production, as the properties can be updated without requiring a cluster restart, which is not possible in the case of file file-based session property manager.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added to the docs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: please revert the whitespace-only changes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: please revert the whitespace-only changes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@tdcmeehan, do we want to split this module?

@libianoss

Copy link
Copy Markdown

@infvg @tdcmeehan pls help to check the comments from @imjalpreet and let's try to complete and merge this PR by this Thur. Thank you.

@infvg infvg force-pushed the db-session-property branch 2 times, most recently from cddc79f to 2de1b16 Compare August 28, 2025 08:16
@infvg infvg requested a review from a team as a code owner August 28, 2025 08:16
@infvg infvg force-pushed the db-session-property branch 2 times, most recently from 7bbcbe2 to 9b01175 Compare August 28, 2025 08:35

@imjalpreet imjalpreet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@infvg, thank you, mostly looks good. Can you please add details regarding the refactor in the commit description as well?

<artifactId>jakarta.validation-api</artifactId>
</dependency>


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: remove extra line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed

<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: keep this new line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

kept

Comment thread presto-file-session-property-manager/pom.xml
Comment thread CODEOWNERS

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it possible to keep a separate commit for this, or does it start erroring out if it's not updated in the same commit?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Split into 2 commits

@infvg infvg force-pushed the db-session-property branch 2 times, most recently from c2ab511 to a0f22ac Compare August 31, 2025 05:36
@libianoss

Copy link
Copy Markdown

@infvg can I ask what's pending for this PR now? @imjalpreet are all things working fine now?

@infvg

infvg commented Sep 1, 2025

Copy link
Copy Markdown
Contributor Author

@libianoss PR is ready for review

@imjalpreet imjalpreet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, @infvg. LGTM % last few nits.

Comment on lines +76 to +89
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<optional>true</optional>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<optional>true</optional>
<scope>runtime</scope>
</dependency>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't need these in this module, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, removed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: please remove these whitespace-only changes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: please remove these whitespace-only changes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed

infvg and others added 2 commits September 1, 2025 13:05
Co-authored-by: Ashish Tadose <ashishtadose@gmail.com>
Co-authored-by: Ariel Weisberg <aweisberg@fb.com>
Co-authored-by: Jalpreet Singh Nanda (:imjalpreet) <jalpreetnanda@gmail.com>
Currently, the presto-session-property-managers module has gotten large due to the different implementations for file based
and db based session property managers. If implemented, this commit will split the module into 3,
``presto-session-property-managers-common`` will contain the API implementation for a session property manager
along with some tests. ``presto-file-session-property-manager`` will contain the file based implementation, and
``presto-db-session-property-manager`` will contain the db based implementation.

@imjalpreet imjalpreet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, @infvg.

@libianoss

Copy link
Copy Markdown

@imjalpreet jal @infvg is this ready to merge?

@libianoss

Copy link
Copy Markdown

@infvg can we get this merged? What's the blocker now?

@libianoss

Copy link
Copy Markdown

@infvg can you response to the request from @pratyakshsharma ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:IBM PR from IBM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants