Skip to content

PHOENIX-6456 Support query logging for DDL and DML - #1210

Closed
richardantal wants to merge 3 commits into
apache:masterfrom
richardantal:PHOENIX-6456
Closed

PHOENIX-6456 Support query logging for DDL and DML#1210
richardantal wants to merge 3 commits into
apache:masterfrom
richardantal:PHOENIX-6456

Conversation

@richardantal

Copy link
Copy Markdown
Contributor

Change-Id: I0f0a39293500201c7a27a8fd8686799fb1668221

@stoty

Copy link
Copy Markdown
Contributor

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec1m 13sDocker 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 51smaster passed
+0hbaserecompile22m 18sHBase recompiled.
+1 💚compile1m 4smaster passed
+1 💚checkstyle1m 58smaster passed
+1 💚javadoc0m 52smaster passed
+0 🆗spotbugs3m 4sphoenix-core in master has 960 extant spotbugs warnings.
_ Patch Compile Tests _
+1 💚mvninstall8m 10sthe patch passed
+0hbaserecompile17m 35sHBase recompiled.
+1 💚compile1m 3sthe patch passed
+1 💚javac1m 3sthe patch passed
-1 ❌checkstyle1m 59sphoenix-core: The patch generated 100 new + 3427 unchanged - 20 fixed = 3527 total (was 3447)
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚javadoc0m 50sthe patch passed
+1 💚spotbugs3m 15sthe patch passed
_ Other Tests _
+1 💚unit115m 50sphoenix-core in the patch passed.
+1 💚asflicense0m 19sThe patch does not generate ASF License warnings.
169m 32s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1210/1/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#1210
Optional Testsdupname asflicense javac javadoc unit spotbugs hbaserebuild hbaseanti checkstyle compile
unameLinux 8037d224f0cf 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 / d1f26c7
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-1210/1/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt
Test Resultshttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1210/1/testReport/
Max. process+thread count12270 (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-1210/1/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.

handlerCount = DEFAULT_AUDIT_LOGGER_PROCESS_COUNT;
}

if (handlerCount == 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.

Can't we just use a workhandler pool with a single worker ?
I think we need not keep QueryLogDetailsEventHandler.

}

public QueryLogger createQueryLogger(CompilableStatement stmt, String sql) throws SQLException {
if (connection.getLogLevel() == LogLevel.OFF) {

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 looks suspect.
Shouldn't we check the audit log status too ?

return compileMutation(stmt, sql);
}

public boolean checkIgnoreQueryAudit(CompilableStatement stmt, String sql) {

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.

We could move the check for ExecutableSelectStatement here.

Comment threadphoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java Outdated
Comment threadphoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java Outdated
Change-Id: I0f0a39293500201c7a27a8fd8686799fb1668221
@stoty

Copy link
Copy Markdown
Contributor

Next time please push a separate commit instead of amending so that I can see what you changed.


boolean isSystemTable = false;
if(stmt instanceof ExecutableSelectStatement) {
public boolean checkIgnoreQueryAudit(CompilableStatement stmt) {

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 is now applies to al logs, so we shouldn't call it checkIgnoreQueryAudit

handlerCount = DEFAULT_AUDIT_LOGGER_PROCESS_COUNT;
}

QueryLogDetailsWorkHandler[] workHandlers = new QueryLogDetailsWorkHandler[handlerCount];

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.

We should remove the old handler, as it is dead code now.

public static final boolean DEFAULT_WILDCARD_QUERY_DYNAMIC_COLS_ATTRIB = false;
public static final String DEFAULT_LOGGING_LEVEL = LogLevel.OFF.name();
public static final String DEFAULT_AUDIT_LOGGING_LEVEL = LogLevel.OFF.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.

nit: no need for the extra empty line

@stoty

Copy link
Copy Markdown
Contributor

Please also do a PR for 4.x when you are done, so that we get a test run on that branch, too.

@stoty

Copy link
Copy Markdown
Contributor

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec1m 9sDocker 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 💚mvninstall16m 25smaster passed
+0hbaserecompile22m 44sHBase recompiled.
+1 💚compile1m 4smaster passed
+1 💚checkstyle1m 57smaster passed
+1 💚javadoc0m 52smaster passed
+0 🆗spotbugs3m 6sphoenix-core in master has 960 extant spotbugs warnings.
_ Patch Compile Tests _
+1 💚mvninstall8m 17sthe patch passed
+0hbaserecompile17m 49sHBase recompiled.
+1 💚compile1m 4sthe patch passed
+1 💚javac1m 4sthe patch passed
-1 ❌checkstyle2m 1sphoenix-core: The patch generated 93 new + 3417 unchanged - 30 fixed = 3510 total (was 3447)
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚javadoc0m 50sthe patch passed
+1 💚spotbugs3m 13sthe patch passed
_ Other Tests _
-1 ❌unit113m 40sphoenix-core in the patch failed.
+1 💚asflicense0m 44sThe patch does not generate ASF License warnings.
170m 16s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1210/2/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#1210
Optional Testsdupname asflicense javac javadoc unit spotbugs hbaserebuild hbaseanti checkstyle compile
unameLinux 3bef68ce11bc 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 / e9de744
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-1210/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-1210/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-1210/2/testReport/
Max. process+thread count9763 (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-1210/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.

Change-Id: Ieb0fed3f245a15297a34752b6a2b95f548eba396
@stoty

Copy link
Copy Markdown
Contributor

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec1m 22sDocker 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 💚mvninstall16m 6smaster passed
+0hbaserecompile23m 49sHBase recompiled.
+1 💚compile1m 2smaster passed
+1 💚checkstyle1m 45smaster passed
+1 💚javadoc0m 53smaster passed
+0 🆗spotbugs3m 12sphoenix-core in master has 960 extant spotbugs warnings.
_ Patch Compile Tests _
+1 💚mvninstall8m 9sthe patch passed
+0hbaserecompile18m 47sHBase recompiled.
+1 💚compile1m 2sthe patch passed
+1 💚javac1m 2sthe patch passed
-1 ❌checkstyle1m 58sphoenix-core: The patch generated 85 new + 3425 unchanged - 36 fixed = 3510 total (was 3461)
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚javadoc0m 52sthe patch passed
+1 💚spotbugs3m 19sphoenix-core generated 0 new + 959 unchanged - 1 fixed = 959 total (was 960)
_ Other Tests _
-1 ❌unit116m 0sphoenix-core in the patch failed.
+1 💚asflicense0m 42sThe patch does not generate ASF License warnings.
174m 37s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1210/3/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#1210
Optional Testsdupname asflicense javac javadoc unit spotbugs hbaserebuild hbaseanti checkstyle compile
unameLinux 44c39a12df4d 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 / e9de744
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-1210/3/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt
unithttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1210/3/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-1210/3/testReport/
Max. process+thread count11955 (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-1210/3/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.

@stotystoty 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 LGTM

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

I'd like to understand the intent of how a user would use this audit logging a bit better before these changes land.

Specifically, it looks like, right now, the log level has to be >= than the audit log level to function. However, I think that's not the intent of your changes. By the changes in this PR, I think you're intending for either the normal log or the audit log to result in data flowing to the system.log table.

In other words, it would be helpful to describe what someones sets in configuration who wants to get the audit logs, and then what these look like when they make it to the system.log table.

Thanks!

syncBase(readMetrics, overAllMetrics, logLevel);
}

public void syncAudit(Map<String, Map<MetricType, Long>> readMetrics, Map<MetricType, Long> overAllMetrics) {

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.

Since your calls to this method are often passing (null, null), how about overloading this method to create

public void syncAudit() {
syncAudit(null, null, LogLevel.TRACE);
}

And then adopt that new call above. Would also be good to have javadoc (especially to denote the difference between sync and syncAudit)

import com.lmax.disruptor.Sequence;
import com.lmax.disruptor.SequenceReportingEventHandler;

public class QueryLogDetailsWorkHandler implements WorkHandler<RingBufferEvent>, LifecycleAware {

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.

Trying to understand the change of type hierarchy. Seems like we didn't actually need the Sequence part of disruptor?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

sequenceCallback was never used in the old implementation.

this.queryId = UUID.randomUUID().toString();
this.queryDisruptor = connection.getQueryServices().getQueryDisruptor();
logLevel = connection.getLogLevel();
auditLogLevel = connection.getAuditLogLevel();

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're only using logLevel to determine when we should instantiate a real QueryLogger instance in getInstance(PhoenixConnection, boolean).

Is the expectation that a user could have audit logging without "normal" logging enabled? Right now, it looks like you have to have at least some "normal" logging enabled to get the audit logging.

I think we would want these to be exclusive (if either normal or audit logging is enabled, we instantiate a real QueryLogger).

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't comment on this line in the code, so putting it here)

We also only get a real QueryLogger when getLogSamplingRate() matches the condition inside getInstance(...). Is it OK to have just one sampling rate for both normal and audit logging?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Great catch Josh!

We would like the QueryLogger work separately from the newly created AuditQueryLogger.
We should log DML and DDL operations when QueryServices.AUDIT_LOG_LEVEL is greater than INFO even if normal logging is disabled. (the default is OFF)
We can have both enabled and if we want to have logging for select queries and for DML + DDL queries, we should.

About the LogSamplingRate
In the latest change I separated AuditQueryLogger and LogSamplingRate has no effect on it, I think If AUDIT_LOG_LEVEL is enabled we should log every query.

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 can have both enabled and if we want to have logging for select queries and for DML + DDL queries, we should.

Great! That sounds like the correct approach.

In the latest change I separated AuditQueryLogger and LogSamplingRate has no effect on it, I think If AUDIT_LOG_LEVEL is enabled we should log every query.

Ok, I think that is fine. Let's make sure we circle back around an update Phoenix documentation for this new feature.

Change-Id: I3a7591c3224ebd54358f322981cde6b1d220002e
auditLogLevel = LogLevel.OFF;
}

public static final AuditQueryLogger NO_OP_INSTANCE = new AuditQueryLogger() {

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.

Looks like this mostly duplicates the NO_OP_INSTANCE in QueryLogger. Could clean this up (in follow-up) to not have the same "shell" of a class.

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

Looks great. Awesome test case addition 👍🏼

@dbwong

dbwong commented Apr 29, 2021

Copy link
Copy Markdown
Contributor

Why the notion of a separate type of logger as opposed to increasing the scope of the queryLogger? More specifically can we make the logging class pluggable and have this as one of the implementations? We can also have a chain-able logger where more than one could be used if necessary.

@joshelser

Copy link
Copy Markdown
Member

Why the notion of a separate type of logger as opposed to increasing the scope of the queryLogger?

The earlier commits on this review actually had them both in one class. It was a little complex to manage not getting a no-op instance when either query logging or audit logging.

@stoty

stoty commented Apr 29, 2021

Copy link
Copy Markdown
Contributor

The motivation for the audit logger is to log all data modifications for compliance purposes.
This is a colossal waste of storage and resources, but some users have this legal requirement.

The goal of the original logging implementation is mostly to provide data for operational purposes and performance optimization.

For example, in query logging, we only log the parameters at trace levels, while in the audit log we always want to log them, as it's useless without this.
We also don't want to to do statistical logging for audit, as it would defeat its purpose.

We have serveral things to log (query, paramters, query plan, statistics, etc)
At the extreme end, you could specify what to log for each query type, and specify the logging probability.
(Possibly complicating this by filtering for tables or other objects)

However, this would be quite a large and awkward matrix to configure.

The current solution is a relatively simple point solution to add the audit logging capability.

It does not preclude the possibility of adding a more full-featured and flexible logging implementation later.

@dbwong

Copy link
Copy Markdown
Contributor

The motivation for the audit logger is to log all data modifications for compliance purposes.
This is a colossal waste of storage and resources, but some users have this legal requirement.

The goal of the original logging implementation is mostly to provide data for operational purposes and performance optimization.

For example, in query logging, we only log the parameters at trace levels, while in the audit log we always want to log them, as it's useless without this.
We also don't want to to do statistical logging for audit, as it would defeat its purpose.

We have serveral things to log (query, paramters, query plan, statistics, etc)
At the extreme end, you could specify what to log for each query type, and specify the logging probability.
(Possibly complicating this by filtering for tables or other objects)

However, this would be quite a large and awkward matrix to configure.

The current solution is a relatively simple point solution to add the audit logging capability.

It does not preclude the possibility of adding a more full-featured and flexible logging implementation later.

This is already pushed but I'm a bit worried about how we migrate users on this to the more full-featured and flexible logging implementation without the approaches I mentioned above. We may have to support this into the future even if it isn't really as flexible as we would like.

@stoty

Copy link
Copy Markdown
Contributor

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec1m 10sDocker 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 30smaster passed
+0hbaserecompile23m 13sHBase recompiled.
+1 💚compile1m 4smaster passed
+1 💚checkstyle1m 57smaster passed
+1 💚javadoc0m 51smaster passed
+0 🆗spotbugs3m 2sphoenix-core in master has 960 extant spotbugs warnings.
_ Patch Compile Tests _
+1 💚mvninstall8m 1sthe patch passed
+0hbaserecompile18m 29sHBase recompiled.
+1 💚compile1m 3sthe patch passed
+1 💚javac1m 3sthe patch passed
-1 ❌checkstyle2m 2sphoenix-core: The patch generated 131 new + 3413 unchanged - 48 fixed = 3544 total (was 3461)
+1 💚whitespace0m 0sThe patch has no whitespace issues.
-1 ❌javadoc0m 50sphoenix-core generated 1 new + 95 unchanged - 1 fixed = 96 total (was 96)
+1 💚spotbugs3m 15sphoenix-core generated 0 new + 959 unchanged - 1 fixed = 959 total (was 960)
_ Other Tests _
-1 ❌unit119m 36sphoenix-core in the patch failed.
+1 💚asflicense0m 50sThe patch does not generate ASF License warnings.
177m 38s
ReasonTests
Failed junit testsphoenix.end2end.AuditLoggingIT
phoenix.end2end.ConcurrentUpsertsWithoutIndexedColsIT
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1210/4/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#1210
Optional Testsdupname asflicense javac javadoc unit spotbugs hbaserebuild hbaseanti checkstyle compile
unameLinux b6487e354de6 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 / e9de744
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-1210/4/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt
javadochttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1210/4/artifact/yetus-general-check/output/diff-javadoc-javadoc-phoenix-core.txt
unithttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1210/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-1210/4/testReport/
Max. process+thread count11089 (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-1210/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.

@joshelser

Copy link
Copy Markdown
Member

how we migrate users on this to the more full-featured and flexible logging implementation without the approaches I mentioned above.

I'm not seeing how this is making things worse -- as it stands, users who were using the query logger can continue to use it as they have been. Those who want to adopt the DDL audit logging can turn that on as they please.

As Istvan points out, there's a big range out what users want when it comes to auditing. I don't see what is in place right now as being burdensome (you have to know it's there and turn it on by default, now). That's not to say we have to leave it this way (I think automatically logging DDLs would be excellent!), but let's focus on what we want this usability to be. Wdyt, Daniel?

@dbwong

dbwong commented Apr 29, 2021

Copy link
Copy Markdown
Contributor

As Istvan points out, there's a big range out what users want when it comes to auditing. I don't see what is in place right now as being burdensome (you have to know it's there and turn it on by default, now). That's not to say we have to leave it this way (I think automatically logging DDLs would be excellent!), but let's focus on what we want this usability to be. Wdyt, Daniel?

I'm not opposed to the short term implementation, i'm just trying to make the end user opt in more generic so we won't have a migration to do in the future, or alternatively have multiple ways to configure query logging. Do I use audit logging/query logging or whatever improvements we build in the future? Which was why I was trying to push for a generalized solution where we specify a logging class, for example phoenix.log.queryLogger=org.apache.phoenix.log.auditLogger. Otherwise we may end up having a giant grid of options like you mentioned. I'm not strongly opposed but note that future improvements may want to completely removing "auditLogger" options, but we will feel obligated to keep them for compatibility.

@stoty

Copy link
Copy Markdown
Contributor

Being able to specify a single logging implementation wouldn't get us far.

To support even the current use case, we'd need to be able to specify the logging class and log level for at least for the queries and the DML/DDL statements separately.

The implementation detail of having a separate logger class is not exposed in the configuration.

Once we figure out how to have more generic logging configuration, the current behaviour can be folded into that.

I think that in more generic configuration we should have single logger and feed all logging events to that. That intelligent logger would then (pre) compute the aforementioned big matrix of what should go into the log based on the query type and what we specified in the new-style configuration, and add/ignore the events based on that.

I agree that we WOULD have to add some backwards compatibility code to map the current settings to the future more flexible method, which is not ideal, but we'll have to do the same for the existing query logger configuration setting anyway.

I gave some thought about how to add redaction to the logging, but it seeems pretty daunting. You could probably flag fields and identify them at statement compilation time, but then you'd have to re-generate the logged query text from the redacted query plan. (And I'm not sure how UDFs would interfere with this)

@joshelser

Copy link
Copy Markdown
Member

Can I suggest this path forward? @richardantal and @stoty, can you please make sure the current functionality is documented on the webiste? Then, let's continue conversation with @dbwong (and others) on the mailing list to figure out, given what we have today, are there any scenarios which are impossible or hard which we would want to improve going forward.

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

@richardantal@stoty@dbwong@joshelser