You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "fallintoplace (via GitHub)" <gi...@apache.org> on 2026/07/28 23:35:52 UTC

[PR] fix(parquet): reject short page writes [arrow-go]

fallintoplace opened a new pull request, #1050:
URL: https://github.com/apache/arrow-go/pull/1050

   ## Summary\n\n- return  when a direct dictionary or data page body write accepts fewer bytes than requested\n- avoid updating page counters and indexes after an incomplete body write\n- cover both direct page paths with a short-writing sink\n\n## Testing\n\n- --- FAIL: TestRleBooleanEncodingFileRead (0.00s)
       file_reader_test.go:517: PARQUET_TEST_DATA not set, using ../../parquet-testing/data
       file_reader_test.go:519: 
           	Error Trace:	/Users/hoangvu/Code/OSS/arrow-go-page-short-write/parquet/file/file_reader_test.go:519
           	Error:      	unable to find file "../../parquet-testing/data"
           	Test:       	TestRleBooleanEncodingFileRead
       file_reader_test.go:524: 
           	Error Trace:	/Users/hoangvu/Code/OSS/arrow-go-page-short-write/parquet/file/file_reader_test.go:524
           	Error:      	Received unexpected error:
           	            	open ../../parquet-testing/data/rle_boolean_encoding.parquet: no such file or directory
           	Test:       	TestRleBooleanEncodingFileRead
   --- FAIL: TestBadReader (0.00s)
       file_reader_test.go:594: PARQUET_TEST_DATA not set, using ../../parquet-testing/data
       file_reader_test.go:596: 
           	Error Trace:	/Users/hoangvu/Code/OSS/arrow-go-page-short-write/parquet/file/file_reader_test.go:596
           	Error:      	unable to find file "../../parquet-testing/data"
           	Test:       	TestBadReader
   --- FAIL: TestByteStreamSplitEncodingFileRead (0.00s)
       file_reader_test.go:627: PARQUET_TEST_DATA not set, using ../../parquet-testing/data
       file_reader_test.go:629: 
           	Error Trace:	/Users/hoangvu/Code/OSS/arrow-go-page-short-write/parquet/file/file_reader_test.go:629
           	Error:      	unable to find file "../../parquet-testing/data"
           	Test:       	TestByteStreamSplitEncodingFileRead
   --- FAIL: TestLZ4RawFileRead (0.00s)
       file_reader_test.go:823: PARQUET_TEST_DATA not set, using ../../parquet-testing/data
       file_reader_test.go:825: 
           	Error Trace:	/Users/hoangvu/Code/OSS/arrow-go-page-short-write/parquet/file/file_reader_test.go:825
           	Error:      	unable to find file "../../parquet-testing/data"
           	Test:       	TestLZ4RawFileRead
   --- FAIL: TestLZ4RawLargerFileRead (0.00s)
       file_reader_test.go:907: PARQUET_TEST_DATA not set, using ../../parquet-testing/data
       file_reader_test.go:909: 
           	Error Trace:	/Users/hoangvu/Code/OSS/arrow-go-page-short-write/parquet/file/file_reader_test.go:909
           	Error:      	unable to find file "../../parquet-testing/data"
           	Test:       	TestLZ4RawLargerFileRead
   --- FAIL: TestDeltaByteArray (0.00s)
       file_reader_test.go:950: PARQUET_TEST_DATA not set, using ../../parquet-testing/data
       file_reader_test.go:952: 
           	Error Trace:	/Users/hoangvu/Code/OSS/arrow-go-page-short-write/parquet/file/file_reader_test.go:952
           	Error:      	unable to find file "../../parquet-testing/data"
           	Test:       	TestDeltaByteArray
   --- FAIL: TestListColumns (0.00s)
       file_reader_test.go:1002: PARQUET_TEST_DATA not set, using ../../parquet-testing/data
       file_reader_test.go:1004: 
           	Error Trace:	/Users/hoangvu/Code/OSS/arrow-go-page-short-write/parquet/file/file_reader_test.go:1004
           	Error:      	unable to find file "../../parquet-testing/data"
           	Test:       	TestListColumns
   FAIL
   FAIL	github.com/apache/arrow-go/v18/parquet/file	5.376s
   FAIL


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(parquet): reject short page writes [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade merged PR #1050:
URL: https://github.com/apache/arrow-go/pull/1050


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(parquet): reject short page writes [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #1050:
URL: https://github.com/apache/arrow-go/pull/1050#discussion_r3722369188


##########
parquet/internal/thrift/helpers.go:
##########
@@ -76,12 +76,23 @@ func (t *Serializer) Serialize(msg thrift.TStruct, w io.Writer, enc encryption.E
 	}
 
 	if enc == nil {
-		return w.Write(b)
+		n, err := w.Write(b)
+		if err != nil {
+			return n, err
+		}
+		if n != len(b) {
+			return n, io.ErrShortWrite
+		}
+		return n, nil
 	}
 
 	var cipherBuf bytes.Buffer
 	cipherBuf.Grow(enc.CiphertextSizeDelta() + len(b))
 	enc.Encrypt(&cipherBuf, b)
+	expected := cipherBuf.Len()
 	n, err := cipherBuf.WriteTo(w)
+	if err == nil && int(n) != expected {
+		err = io.ErrShortWrite
+	}

Review Comment:
   same as above, err will be non-nil on a short write, so you don't need to do this



##########
parquet/file/page_writer.go:
##########
@@ -400,7 +400,13 @@ func (pw *serializedPageWriter) WriteDataPage(page DataPage) (int64, error) {
 	if err != nil {
 		return int64(written), err
 	}
+	if written != len(data) {
+		return int64(written), io.ErrShortWrite
+	}

Review Comment:
   same comment as above, err will always be non-nil if written < len(data)



##########
parquet/file/page_writer.go:
##########
@@ -337,8 +334,14 @@ func (pw *serializedPageWriter) WriteDictionaryPage(page *DictionaryPage) (int64
 	if err != nil {
 		return 0, err
 	}
+	if written != len(data) {
+		return int64(written), io.ErrShortWrite
+	}

Review Comment:
   this is unnecessary, Write will always return a non-nil error if `written < len(data)`



##########
parquet/internal/thrift/helpers.go:
##########
@@ -76,12 +76,23 @@ func (t *Serializer) Serialize(msg thrift.TStruct, w io.Writer, enc encryption.E
 	}
 
 	if enc == nil {
-		return w.Write(b)
+		n, err := w.Write(b)
+		if err != nil {
+			return n, err
+		}
+		if n != len(b) {
+			return n, io.ErrShortWrite
+		}

Review Comment:
   same comment as above, this isn't necessary since Write will return a non-nil error on a short write



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org