You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-issues@hadoop.apache.org by "Ayush Saxena (Jira)" <ji...@apache.org> on 2020/12/04 07:45:00 UTC
[jira] [Commented] (HDFS-15442) Image upload may fail if
dfs.image.transfer.chunksize wrongly set to negative value
[ https://issues.apache.org/jira/browse/HDFS-15442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17243799#comment-17243799 ]
Ayush Saxena commented on HDFS-15442:
-------------------------------------
Thanx [~AMC-team] for the patch.
The build results weren't that good, and aren't available too(blame me for coming back so late). I have retriggered it, If everything is good, Will commit, by today EOD
> Image upload may fail if dfs.image.transfer.chunksize wrongly set to negative value
> -----------------------------------------------------------------------------------
>
> Key: HDFS-15442
> URL: https://issues.apache.org/jira/browse/HDFS-15442
> Project: Hadoop HDFS
> Issue Type: Bug
> Reporter: AMC-team
> Assignee: AMC-team
> Priority: Major
> Attachments: HDFS-15442.000.patch
>
>
> In current implementation of checkpoint image transfer, if the file length is bigger than the configured value dfs.image.transfer.chunksize, it will use chunked streaming mode to avoid internal buffering. This mode should be used only if more than chunkSize data is present to upload, otherwise upload may not happen sometimes.
> {code:java}
> //TransferFsImage.java
> int chunkSize = (int) conf.getLongBytes(
> DFSConfigKeys.DFS_IMAGE_TRANSFER_CHUNKSIZE_KEY,
> DFSConfigKeys.DFS_IMAGE_TRANSFER_CHUNKSIZE_DEFAULT);
> if (imageFile.length() > chunkSize) {
> // using chunked streaming mode to support upload of 2GB+ files and to
> // avoid internal buffering.
> // this mode should be used only if more than chunkSize data is present
> // to upload. otherwise upload may not happen sometimes.
> connection.setChunkedStreamingMode(chunkSize);
> }
> {code}
> There is no check code for this parameter. User may accidentally set this value to a wrong value. Here, if the user set chunkSize to a negative value. Chunked streaming mode will always be used. In setChunkedStreamingMode(chunkSize), there is a correction code that if the chunkSize is <=0, it will be change to DEFAULT_CHUNK_SIZE.
> {code:java}
> public void setChunkedStreamingMode (int chunklen) {
> if (connected) {
> throw new IllegalStateException ("Can't set streaming mode: already connected");
> }
> if (fixedContentLength != -1 || fixedContentLengthLong != -1) {
> throw new IllegalStateException ("Fixed length streaming mode set");
> }
> chunkLength = chunklen <=0? DEFAULT_CHUNK_SIZE : chunklen;
> }
> {code}
> However,
> *If the user set dfs.image.transfer.chunksize to value that <= 0, even for images whose imageFile.length() < DEFAULT_CHUNK_SIZE will use chunked streaming mode and may fail the upload as mentioned above.* *(This scenario may not be common, but* *we can prevent users setting this param to an extremely small value.**)*
> *How to fix:*
> Add checking code or correction code right after parsing the config value before really use the value (setChunkedStreamingMode).
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org