Add a DB based session property manager#24995
Conversation
b9191b4 to
a405418
Compare
064f35e to
9f7283f
Compare
c335922 to
b29057b
Compare
pratyakshsharma
left a comment
There was a problem hiding this comment.
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.
f174a51 to
fd53f8b
Compare
steveburnett
left a comment
There was a problem hiding this comment.
Thanks for the documentation! A few suggestions.
78ac74c to
30a553c
Compare
steveburnett
left a comment
There was a problem hiding this comment.
Minor phrasing suggestion.
30a553c to
4c6495f
Compare
steveburnett
left a comment
There was a problem hiding this comment.
LGTM! (docs)
Pull updated branch, new local doc build, looks good. Thanks!
imjalpreet
left a comment
There was a problem hiding this comment.
@infvg, thank you, I finished my first pass, please have a look.
| 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@infvg I think we should also add a brief description of every new property introduced. @steveburnett, do you think that would be useful?
There was a problem hiding this comment.
@imjalpreet yes, I agree. All properties should be documented. See Designing Your Code section iii in CONTRIBUTING.md.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
This table is present in the MySQL DB. The CLI prompt presto:tpch> is a little confusing.
There was a problem hiding this comment.
Maybe we should show output from MySQL CLI rather than Presto CLI.
|
|
||
| .. code-block:: text | ||
|
|
||
| presto:tpch> DESCRIBE session_client_tags; |
There was a problem hiding this comment.
This table is present in the MySQL DB. The CLI prompt presto:tpch> is a little confusing.
|
|
||
| .. code-block:: text | ||
|
|
||
| presto:tpch> DESCRIBE session_property_values; |
There was a problem hiding this comment.
This table is present in the MySQL DB. The CLI prompt presto:tpch> is a little confusing.
| 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. |
There was a problem hiding this comment.
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.
| import static com.facebook.presto.session.file.FileSessionPropertyManager.CODEC; | ||
| import static org.testng.Assert.assertEquals; | ||
|
|
||
| public class TestFileSessionPropertyManager |
There was a problem hiding this comment.
Can we add a similar test for the DB-based session property manager?
| return resourceGroupManager; | ||
| } | ||
|
|
||
| public SessionPropertyDefaults getSessionPropertyDefaults() |
There was a problem hiding this comment.
Do we need the changes in this file? I don't see any usage.
| <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> |
There was a problem hiding this comment.
I don't see any tests added yet that are using this dependency.
There was a problem hiding this comment.
Changed to similar mysql dependencies that are used in the new tests.
| @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(); | ||
| } | ||
| } |
There was a problem hiding this comment.
We shouldn't override these. Based on what I understand, we can just override the abstract method: getSessionMatchSpecs in all implementations of AbstractSessionPropertyManager
imjalpreet
left a comment
There was a problem hiding this comment.
@infvg, please rebase on the latest master as well to trigger all tests.
27e542f to
f1c7154
Compare
imjalpreet
left a comment
There was a problem hiding this comment.
@infvg, thank you! Mostly LGTM, just a couple of suggestions.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
nit: please revert the whitespace-only changes
There was a problem hiding this comment.
nit: please revert the whitespace-only changes
|
@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. |
cddc79f to
2de1b16
Compare
7bbcbe2 to
9b01175
Compare
imjalpreet
left a comment
There was a problem hiding this comment.
@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> | ||
|
|
||
|
|
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-core</artifactId> | ||
| </dependency> | ||
|
|
There was a problem hiding this comment.
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?
c2ab511 to
a0f22ac
Compare
|
@infvg can I ask what's pending for this PR now? @imjalpreet are all things working fine now? |
|
@libianoss PR is ready for review |
imjalpreet
left a comment
There was a problem hiding this comment.
Thank you, @infvg. LGTM % last few nits.
| <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> | ||
|
|
There was a problem hiding this comment.
We shouldn't need these in this module, right?
There was a problem hiding this comment.
nit: please remove these whitespace-only changes
There was a problem hiding this comment.
nit: please remove these whitespace-only changes
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 jal @infvg is this ready to merge? |
|
@infvg can we get this merged? What's the blocker now? |
|
@infvg can you response to the request from @pratyakshsharma ? |
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=dbTest Plan
Unit tests
Contributor checklist
Release Notes