New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(TEPHRA-219) Execute cross region calls in Coprocessor as the login user #35
(TEPHRA-219) Execute cross region calls in Coprocessor as the login user #35
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gokulavasan I have a couple of comments. Also the build is still failing at the prune writer test.
LOG.debug("Automatic invalid list pruning is enabled. Compaction state will be recorded in table " | ||
+ pruneTable); | ||
} | ||
Configuration conf = getConfiguration(c.getEnvironment()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to read the configuration every time since it does not change when part of hbase-site.xml, right? We just need to make sure that when derived classes update the pruneEnable and other fields from a different thread, it gets reflected here.
while ((!isInterrupted()) && isRunning()) { | ||
Service.State serviceState = state(); | ||
while ((!isInterrupted()) && | ||
(serviceState.equals(Service.State.NEW) || serviceState.equals(Service.State.STARTING) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm - do you think it would simplify the code if we go back to using a stop
flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes might be simpler
Map.Entry<byte[], Long> firstEntry = pruneEntries.firstEntry(); | ||
dataJanitorState.savePruneUpperBoundForRegion(firstEntry.getKey(), firstEntry.getValue()); | ||
final Map.Entry<byte[], Long> firstEntry = pruneEntries.firstEntry(); | ||
User.runAsLoginUser(new PrivilegedExceptionAction<Void>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding User.runAsLoginUser
here brings in unnecessary security code into PruneUpperBoundWriter
class. Also if we modify TransactionProcessor
later to add other table operations, we may miss to wrap those calls. I think it would be better to do the wrapping in TransactionProcessor
class itself. What do you say?
18fa4fc
to
9bc97ee
Compare
@poornachandra The build is failing in a different compat module due to the PruneUpperBoundWriter issue that I have fixed in compat-1.1-base module. Once we port the changes to other modules, it should fix the build. |
7692066
to
909adcb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gokulavasan Just a couple of minor comments
TxConstants.TransactionPruning.DEFAULT_PRUNE_FLUSH_INTERVAL)); | ||
compactionState = new CompactionState(c.getEnvironment(), TableName.valueOf(pruneTable), pruneFlushInterval); | ||
// pruneTable and pruneFlushInterval cannot be changed by simply loading the Configuration dynamically | ||
// since we have only one flush thread across all regions and we might loose. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment can be removed now
if (Boolean.TRUE.equals(pruneEnable)) { | ||
// Record tx state before the compaction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is still relevant, no?
protected void resetPruneState() { | ||
pruneEnable = false; | ||
if (compactionState != null) { | ||
compactionState.stop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to reset compactionState
to null
here.
// Persist the compaction state after a succesful compaction | ||
if (compactionState != null) { | ||
// Persist the compaction state after a successful compaction | ||
if (Boolean.TRUE.equals(pruneEnable)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to change this check to compactionState != null
. Otherwise there is a race condition during initializePruneState()
, where pruneEnable
could be true
, but compactionState
is still not initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gokulavasan Just one comment on a javadoc. Please fix and port to other compat modules.
Configuration conf = getConfiguration(c.getEnvironment()); | ||
// Configuration won't be null in TransactionProcessor but the derived classes might return | ||
// null if it is not available temporarily | ||
protected void initializePruneState(RegionCoprocessorEnvironment env) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to add javadoc for the protected method
// possible that a new value for the same key has been added | ||
emptyRegions.remove(firstEntry.getKey(), firstEntry.getValue()); | ||
} | ||
User.runAsLoginUser(new PrivilegedExceptionAction<Void>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not close TEPHRA-219 until we have figured out how to handle the wrapping cleanly.
4aa5a5e
to
b69577a
Compare
LGTM |
Make pruneEnable and txMaxLifetimeMillis volatile so that derived classes can make use of it. Introduced stopped variable in PruneUpperBoundWriter.
2a142f4
to
6533a4c
Compare
i) Fixes a problem where the pruneThread would exit if the state of the service is not yet set to RUNNING state. This also fixes the flakiness in the PruneUpperBoundSupplierTest which was caused due to the above problem.
ii) Load the txMaxLifeTimeMillis and pruneEnable properties dynamically.
iii) Add a hook around cross region calls in the PruneUpperBoundWriter.