-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-28107 Limit max count of rows filtered per scan request. #5428
base: master
Are you sure you want to change the base?
Conversation
@bbeaudreault hi, could you review code and provide some suggestions if you are available? Thanks! |
1b49f38
to
4f1cca2
Compare
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
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.
Are you sure this is necessary? I agree that heavily filtered scans can cause problems. As of recently, this should be mostly mitigated with the improvements around blockBytesScanned (HBASE-27227, HBASE-27532, HBASE-27558).
So with those jiras, a heavily filtered scan will have a high volume of blockBytesScanned. This will cause those scans to checkpoint more often due to max scan size limits, so they won't hold up RPC handlers. You can then use quotas to limit these scans, so they don't have to be hard failed instead slowed down.
I prefer that approach over this one because in my experience failing a request is an extreme response which can have consequences for users. Fixing the scan requires figuring out why and pushing code to production, which is time consuming and in the meantime the user queries are failing. Another big problem with filtered rows is it doesn't necessarily happen right as you deploy a new scan workload. It may work fine for a while but over time rows get written that dont match your filters, so one day your scan just starts failing due to the limits.
What do you think? Do you want to give the above jiras a try?
public static final String HBASE_SERVER_SCANNER_MAX_ROWS_FILTERED_PER_REQUEST_KEY = | ||
"hbase.server.scanner.max.rows.filtered.per.request"; | ||
|
||
private static RegionScannerLimiter INSTANCE; |
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.
Better not use the singleton pattern here. Just create a RegionScannerLimiter per region server and store it as a field of HRegionServer?
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.
done.
updateLimiterConf(conf, HBASE_SERVER_SCANNER_MAX_ROWS_FILTERED_PER_REQUEST_KEY); | ||
} | ||
|
||
private void updateLimiterConf(Configuration conf, String configKey) { |
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.
The config key is always HBASE_SERVER_SCANNER_MAX_ROWS_FILTERED_PER_REQUEST_KEY? Do we really need to pass it as a parameter?
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.
done.
@bbeaudreault hi, Thank you very much for your reply. I roughly looked at above jiras, they are indeed very useful. But I found a scenario that seems not to be covered? If the data that needs to be filtered only exists in the memstore, can the user's scan request be restricted? Besides, I think my implementation is relatively simple, maybe it can also be an option for users to quickly kill heavily filtered scan requests? What do you think? |
🎊 +1 overall
This message was automatically generated. |
Yea currently it doesn't handle the memstore, but we are hoping to add that in the future. Since this feature here is optional, I don't have a problem with adding it. I just think in general hard failures like this are hard to react to in production, so hopefully disabled by default. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
Thank you very much for your suggestion, I have added it to the |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@Apache9 @bbeaudreault hi, I have changed code a bit, with the limitation of the maximum filtered rows for each scan request, and allowing users to optionally kill the scan request. Could you review code for me if you are available? Thanks! |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
Gentle ping @Apache9 If u have time, could u help review this? Thanks! |
return false; | ||
} | ||
|
||
long countOfRowsFiltered = scannerContext.getMetrics().countOfRowsFiltered.incrementAndGet(); |
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'd better not mix things up with metrics? Metrics is not a critical thing usually.
@@ -467,6 +467,7 @@ public enum NextState { | |||
MORE_VALUES(true, false), | |||
NO_MORE_VALUES(false, false), | |||
SIZE_LIMIT_REACHED(true, true), | |||
FILTERED_ROWS_LIMIT_REACHED(true, true), |
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.
Why not store the limit value in ScannerContext?
@Apache9 @bbeaudreault hi, I have made some code modifications, could you review code and provide some suggestions if you are available? Thanks! |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
Detail: https://issues.apache.org/jira/browse/HBASE-28107