You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@parquet.apache.org by "parthchandra (via GitHub)" <gi...@apache.org> on 2023/02/20 19:51:49 UTC
[GitHub] [parquet-mr] parthchandra opened a new pull request, #1032: PARQUET-2164: Check size of buffered data to prevent page data from overflowing
parthchandra opened a new pull request, #1032:
URL: https://github.com/apache/parquet-mr/pull/1032
This PR addresses the following [PARQUET-2164](https://issues.apache.org/jira/browse/PARQUET-2164)
The configuration parameters
```
parquet.page.size.check.estimate=false
parquet.page.size.row.check.min=<check_size>
parquet.page.size.row.check.max=<check_size>
```
address the reported problem. However the issue can still be hit because the default value of `parquet.page.size.check.estimate` is `true`.
This PR simply adds a check to make sure that `CapacityByteArrayOutputStream` cannot overflow but will instead throw an exception.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [parquet-mr] cxzl25 commented on pull request #1032: PARQUET-2164: Check size of buffered data to prevent page data from overflowing
Posted by "cxzl25 (via GitHub)" <gi...@apache.org>.
cxzl25 commented on PR #1032:
URL: https://github.com/apache/parquet-mr/pull/1032#issuecomment-1437794593
Is it also similar to #1031 ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [parquet-mr] wgtmac commented on a diff in pull request #1032: PARQUET-2164: Check size of buffered data to prevent page data from overflowing
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #1032:
URL: https://github.com/apache/parquet-mr/pull/1032#discussion_r1113858179
##########
parquet-common/src/main/java/org/apache/parquet/bytes/CapacityByteArrayOutputStream.java:
##########
@@ -164,6 +164,15 @@ public CapacityByteArrayOutputStream(int initialSlabSize, int maxCapacityHint, B
private void addSlab(int minimumSize) {
int nextSlabSize;
+ // check for overflow
+ try {
+ Math.addExact(bytesUsed, minimumSize);
+ } catch (ArithmeticException e) {
+ // This is interpreted as a request for a value greater than Integer.MAX_VALUE
+ // We throw OOM because that is what java.io.ByteArrayOutputStream also does
+ throw new OutOfMemoryError("Size of data exceeded 2GB (" + e.getMessage() + ")");
Review Comment:
The error message mismatches the check above. Should we compare with 2GB explicitly or change the message?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [parquet-mr] wgtmac merged pull request #1032: PARQUET-2164: Check size of buffered data to prevent page data from overflowing
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac merged PR #1032:
URL: https://github.com/apache/parquet-mr/pull/1032
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [parquet-mr] parthchandra commented on a diff in pull request #1032: PARQUET-2164: Check size of buffered data to prevent page data from overflowing
Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on code in PR #1032:
URL: https://github.com/apache/parquet-mr/pull/1032#discussion_r1114670273
##########
parquet-common/src/main/java/org/apache/parquet/bytes/CapacityByteArrayOutputStream.java:
##########
@@ -164,6 +164,15 @@ public CapacityByteArrayOutputStream(int initialSlabSize, int maxCapacityHint, B
private void addSlab(int minimumSize) {
int nextSlabSize;
+ // check for overflow
+ try {
+ Math.addExact(bytesUsed, minimumSize);
+ } catch (ArithmeticException e) {
+ // This is interpreted as a request for a value greater than Integer.MAX_VALUE
+ // We throw OOM because that is what java.io.ByteArrayOutputStream also does
+ throw new OutOfMemoryError("Size of data exceeded 2GB (" + e.getMessage() + ")");
Review Comment:
The exception thrown by Math.exact will happen only if integer overflow occurs which happens when the data exceeds 2GB (i.e greater than `Integer.MAX_VALUE` ).
What message were you thinking?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [parquet-mr] parthchandra commented on a diff in pull request #1032: PARQUET-2164: Check size of buffered data to prevent page data from overflowing
Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on code in PR #1032:
URL: https://github.com/apache/parquet-mr/pull/1032#discussion_r1113658117
##########
parquet-common/src/main/java/org/apache/parquet/bytes/CapacityByteArrayOutputStream.java:
##########
@@ -164,6 +164,12 @@ public CapacityByteArrayOutputStream(int initialSlabSize, int maxCapacityHint, B
private void addSlab(int minimumSize) {
int nextSlabSize;
+ if (bytesUsed + minimumSize < 0) {
Review Comment:
Updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [parquet-mr] wgtmac commented on a diff in pull request #1032: PARQUET-2164: Check size of buffered data to prevent page data from overflowing
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #1032:
URL: https://github.com/apache/parquet-mr/pull/1032#discussion_r1115168960
##########
parquet-common/src/main/java/org/apache/parquet/bytes/CapacityByteArrayOutputStream.java:
##########
@@ -164,6 +164,15 @@ public CapacityByteArrayOutputStream(int initialSlabSize, int maxCapacityHint, B
private void addSlab(int minimumSize) {
int nextSlabSize;
+ // check for overflow
+ try {
+ Math.addExact(bytesUsed, minimumSize);
+ } catch (ArithmeticException e) {
+ // This is interpreted as a request for a value greater than Integer.MAX_VALUE
+ // We throw OOM because that is what java.io.ByteArrayOutputStream also does
+ throw new OutOfMemoryError("Size of data exceeded 2GB (" + e.getMessage() + ")");
Review Comment:
If we simply do an overflow check here, then the error message should say `Integer.MAX_VALUE` instead of `2GB`. Otherwise, we should explicitly check if the addition result exceeds 2GB. WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [parquet-mr] wgtmac commented on a diff in pull request #1032: PARQUET-2164: Check size of buffered data to prevent page data from overflowing
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #1032:
URL: https://github.com/apache/parquet-mr/pull/1032#discussion_r1112489810
##########
parquet-common/src/main/java/org/apache/parquet/bytes/CapacityByteArrayOutputStream.java:
##########
@@ -164,6 +164,12 @@ public CapacityByteArrayOutputStream(int initialSlabSize, int maxCapacityHint, B
private void addSlab(int minimumSize) {
int nextSlabSize;
+ if (bytesUsed + minimumSize < 0) {
Review Comment:
nit: replace it with `Math.addExact` to hand over overflow check. Then we get the chance to check the 2GB hard limit before it becoming negative
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [parquet-mr] parthchandra commented on a diff in pull request #1032: PARQUET-2164: Check size of buffered data to prevent page data from overflowing
Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on code in PR #1032:
URL: https://github.com/apache/parquet-mr/pull/1032#discussion_r1114670273
##########
parquet-common/src/main/java/org/apache/parquet/bytes/CapacityByteArrayOutputStream.java:
##########
@@ -164,6 +164,15 @@ public CapacityByteArrayOutputStream(int initialSlabSize, int maxCapacityHint, B
private void addSlab(int minimumSize) {
int nextSlabSize;
+ // check for overflow
+ try {
+ Math.addExact(bytesUsed, minimumSize);
+ } catch (ArithmeticException e) {
+ // This is interpreted as a request for a value greater than Integer.MAX_VALUE
+ // We throw OOM because that is what java.io.ByteArrayOutputStream also does
+ throw new OutOfMemoryError("Size of data exceeded 2GB (" + e.getMessage() + ")");
Review Comment:
The exception thrown by Math.exact will happen only if integer overflow occurs which happens when the data exceeds 2GB (i.e greater than `Integer.MAX_VALUE` ).
What were you thinking of changing the message to?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [parquet-mr] parthchandra commented on a diff in pull request #1032: PARQUET-2164: Check size of buffered data to prevent page data from overflowing
Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on code in PR #1032:
URL: https://github.com/apache/parquet-mr/pull/1032#discussion_r1117357547
##########
parquet-common/src/main/java/org/apache/parquet/bytes/CapacityByteArrayOutputStream.java:
##########
@@ -164,6 +164,15 @@ public CapacityByteArrayOutputStream(int initialSlabSize, int maxCapacityHint, B
private void addSlab(int minimumSize) {
int nextSlabSize;
+ // check for overflow
+ try {
+ Math.addExact(bytesUsed, minimumSize);
+ } catch (ArithmeticException e) {
+ // This is interpreted as a request for a value greater than Integer.MAX_VALUE
+ // We throw OOM because that is what java.io.ByteArrayOutputStream also does
+ throw new OutOfMemoryError("Size of data exceeded 2GB (" + e.getMessage() + ")");
Review Comment:
Let me just change the message.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org