Skip to content

PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes() - #928

Closed
virajjasani wants to merge 1 commit into
apache:masterfrom
virajjasani:PHOENIX-6192-master
Closed

PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes()#928
virajjasani wants to merge 1 commit into
apache:masterfrom
virajjasani:PHOENIX-6192-master

Conversation

@virajjasani

Copy link
Copy Markdown
Contributor

No description provided.

@stoty

Copy link
Copy Markdown
Contributor

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec1m 6sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
+1 💚@author0m 0sThe patch does not contain any @author tags.
-1 ❌test4tests0m 0sThe patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ master Compile Tests _
+1 💚mvninstall36m 32smaster passed
+1 💚compile0m 57smaster passed
+1 💚checkstyle0m 59smaster passed
+1 💚javadoc0m 43smaster passed
+0 🆗spotbugs2m 51sphoenix-core in master has 973 extant spotbugs warnings.
_ Patch Compile Tests _
+1 💚mvninstall32m 54sthe patch passed
+1 💚compile0m 50sthe patch passed
+1 💚javac0m 50sthe patch passed
-1 ❌checkstyle1m 0sphoenix-core: The patch generated 12 new + 1278 unchanged - 11 fixed = 1290 total (was 1289)
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚javadoc0m 42sthe patch passed
+1 💚spotbugs3m 2sthe patch passed
_ Other Tests _
-1 ❌unit172m 45sphoenix-core in the patch failed.
+1 💚asflicense0m 26sThe patch does not generate ASF License warnings.
257m 29s
SubsystemReport/Notes
DockerClientAPI=1.40 ServerAPI=1.40 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/2/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#928
Optional Testsdupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile
unameLinux 1884fa74806d 4.15.0-65-generic #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev/phoenix-personality.sh
git revisionmaster / 5b58d9b
Default JavaPrivate Build-1.8.0_242-8u242-b08-0ubuntu3~16.04-b08
checkstylehttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/2/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt
unithttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/2/artifact/yetus-general-check/output/patch-unit-phoenix-core.txt
Test Resultshttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/2/testReport/
Max. process+thread count6751 (vs. ulimit of 30000)
modulesC: phoenix-core U: phoenix-core
Console outputhttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/2/console
versionsgit=2.7.4 maven=3.3.9 spotbugs=4.1.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

long cacheFreq = rs.getLong(1);
assertEquals(0, cacheFreq);

updateCacheFreq(conn, null, TABLE_NAME, 500);

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.

nit: maybe use tableNameFreqVal instead of entering a numerical value?

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class GlobalConnectionTenantTable2IT extends BaseTest {

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.

Just wondering, can these tests can't be added to GlobalConnectionTenantTableIT itself?

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.

In case the answer is no for some reason, can we rename this test class to be more representative of the actual test i.e. all tests are related to syncUpdateCacheFreq so maybe rename it to show that

}
}

private void updateCacheFreq(Connection conn, String tenantId,

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.

nit: Maybe this method should be called updateUpdateCacheFreq() ;)

"SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+ TABLE_NAME + "'");
rs.next();
long cacheFreq = rs.getLong(1);

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.

nit: Not sure we need to assign rs.get..() to a variable each time for tenantId, ucf, etc. Up to you if you think it's good for clarity (I don't feel strongly about it).

assertEquals(500, cacheFreq);

rs = conn.createStatement().executeQuery(
"SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"

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.

Extract this query into a private final String member variable to avoid duplication

updateCacheFreq(conn, TENANT_NAME, VIEW1_NAME, 999);
updateCacheFreq(conn, TENANT_NAME, VIEW1_INDEX_NAME, 888);

rs = conn.createStatement().executeQuery(

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.

nit: these 4-5 steps are repeated multiple times so maybe worth extracting to a small helper method..something like assertUpdateCacheFreqValue())

cacheFreq = rs.getLong(3);
assertEquals(TENANT_NAME,tenantId);
assertEquals(SCHEMA_NAME, schemaName);
assertEquals(500, cacheFreq);

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.

Similarly, shouldn't this be 0 since VIEW2 has 0 set?

try (Connection conn = getTenantConnection(TENANT_NAME)) {
createView(conn, SCHEMA_NAME, VIEW1_NAME, TABLE_NAME);
createViewIndex(conn, SCHEMA_NAME, VIEW1_INDEX_NAME, VIEW1_NAME, VIEW_INDEX_COL);
createView(conn, SCHEMA_NAME, VIEW2_NAME, VIEW1_NAME);

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.

Would be better to try out a couple of different TENANT_IDs to make sure that syncUpdateCacheFreqAllIndexes() changes the tenant_id to use as per each view that is found

throws SQLException {
String viewName = SchemaUtil.getTableName(tableInfo.getSchemaName(),
tableInfo.getTableName());
String viewTenantId = Bytes.toString(tableInfo.getTenantId());

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.

It will be better to resolve the PTable for the view (either using tenanted connection if required or a global connection if a global view) and then call syncUpdateCacheFreqForIndexesOfTable() just once. Basically, combine this method and getViewAndSyncCacheFreqForIndexes().

}
}

private static void iterateOverChildViewAndSyncCacheFreq(

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.

Rename this method since we aren't iterating over anything. Maybe after combining this with getViewAndSyncCacheFreqForIndexes() we can just call it the latter.

view = PhoenixRuntime.getTable(conn, viewName);
} catch (TableNotFoundException e) {
// Ignore
LOGGER.warn("Error getting PTable for view: {}", viewName);

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.

This should be ERROR level

cacheFreq = rs.getLong(1);
assertEquals(0, cacheFreq);

updateCacheFreq(conn, TENANT_NAME, VIEW1_NAME, 999);

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.

nit: maybe use viewName1FreqVal instead of entering a numerical value?

@yanxinyi

Copy link
Copy Markdown
Contributor

@virajjasani thanks for the patch. Can you rebase and solve the conflict?

@stoty

Copy link
Copy Markdown
Contributor

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec0m 0sDocker mode activated.
-1 ❌docker3m 33sDocker failed to build yetus/phoenix:10ef71711.
SubsystemReport/Notes
GITHUB PR#928
Console outputhttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/3/console
versionsgit=2.17.1
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@virajjasani

Copy link
Copy Markdown
ContributorAuthor

Thanks for the review @ChinmaySKulkarni@yanxinyi . I have addressed your comments, could you please take a look?

@stoty

Copy link
Copy Markdown
Contributor

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec6m 42sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
+1 💚@author0m 0sThe patch does not contain any @author tags.
-1 ❌test4tests0m 0sThe patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ master Compile Tests _
+1 💚mvninstall15m 46smaster passed
+1 💚compile1m 11smaster passed
+1 💚checkstyle1m 1smaster passed
+1 💚javadoc1m 1smaster passed
+0 🆗spotbugs3m 59sphoenix-core in master has 970 extant spotbugs warnings.
_ Patch Compile Tests _
+1 💚mvninstall10m 11sthe patch passed
+1 💚compile1m 9sthe patch passed
+1 💚javac1m 9sthe patch passed
-1 ❌checkstyle1m 0sphoenix-core: The patch generated 4 new + 1296 unchanged - 3 fixed = 1300 total (was 1299)
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚javadoc0m 55sthe patch passed
+1 💚spotbugs4m 2sthe patch passed
_ Other Tests _
-1 ❌unit174m 50sphoenix-core in the patch failed.
+1 💚asflicense0m 28sThe patch does not generate ASF License warnings.
225m 0s
ReasonTests
Failed junit testsphoenix.end2end.index.IndexUsageIT
SubsystemReport/Notes
DockerClientAPI=1.40 ServerAPI=1.40 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/4/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#928
Optional Testsdupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile
unameLinux 0da729dfccb7 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev/phoenix-personality.sh
git revisionmaster / 8c81131
Default JavaPrivate Build-1.8.0_242-8u242-b08-0ubuntu3~16.04-b08
checkstylehttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/4/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt
unithttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/4/artifact/yetus-general-check/output/patch-unit-phoenix-core.txt
Test Resultshttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/4/testReport/
Max. process+thread count6823 (vs. ulimit of 30000)
modulesC: phoenix-core U: phoenix-core
Console outputhttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/4/console
versionsgit=2.7.4 maven=3.3.9 spotbugs=4.1.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@ChinmaySKulkarniChinmaySKulkarni 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.

+1. Thanks @virajjasani

@yanxinyiyanxinyi 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 patch

@virajjasani
virajjasani deleted the PHOENIX-6192-master branch October 25, 2020 17:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@virajjasani@stoty@yanxinyi@ChinmaySKulkarni