[ 
https://issues.apache.org/jira/browse/CAMEL-27456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on CAMEL-27456 started by shashank.
----------------------------------------
> camel-aws2-s3 - streaming upload with timestampGroupingEnabled mixes the 
> bytes of exchanges sent concurrently in one object, and the timeout flush can 
> cut an exchange into two objects
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27456
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27456
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-aws2
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>
> h3. What happens
> With {{streamingUploadMode=true}} and {{timestampGroupingEnabled=true}}, 
> {{processWithTimestampGrouping}} reads the body of an exchange in chunks 
> ({{bufferSize}}, or {{partSize}} with {{multiPartUpload}}) and takes the 
> producer's lock once per chunk. Between two chunks of one exchange the lock 
> is free, so:
> * another exchange of the same time window writes its bytes into the window's 
> upload. The stored object then holds the bytes of the two exchanges mixed: 
> with {{bufferSize=4096}}, an exchange A of 8192 bytes and an exchange B of 
> 8192 bytes sent at the same time give an object of 4096 bytes of A, the 8192 
> bytes of B, then the last 4096 bytes of A. Each exchange returns success. No 
> failure and no timeout is needed, only two exchanges of one window at the 
> same time (concurrent consumers, parallel splits, {{threads()}}).
> * the {{streamingUploadTimeout}} task can flush the window between two 
> chunks: the first part of the exchange is stored in one object and the rest 
> in the next one.
> CAMEL-26539 fixed the same problem without timestamp grouping by holding the 
> lock for the whole exchange; its upgrade note scoped the change to the path 
> without {{timestampGroupingEnabled}}, so this path kept the lock per chunk. 
> The window lookup and the message count of the window ({{state.index++}}) 
> were also done without the lock.
> h3. How to reproduce
> A mocked {{S3Client}} that keeps the completed objects; 
> {{timestampGroupingEnabled=true}}, {{bufferSize=4096}}; exchange A (8192 x 
> 'A') whose body stream waits after its first 4096 bytes, exchange B (8192 x 
> 'B') of the same window sent meanwhile, then stop: the object is {{4096 A + 
> 8192 B + 4096 A}}. With {{streamingUploadTimeout=50}} and only exchange A: 
> two objects of 4096 x 'A'.
> Found with a TLA+ model of the timestamp grouping path (producer threads with 
> two-chunk exchanges, the timeout task, one window, an S3 fake per upload), 
> then reproduced on the real producer.
> h3. Fix
> Hold the lock for the whole exchange, as CAMEL-26539 does without timestamp 
> grouping: the window lookup, the reads of the body and the writes and S3 
> calls of each chunk run under it. No S3 call is added under the lock (they 
> were made under it before, one chunk at a time); the other exchanges of the 
> producer (of any window), the timeout flush and a stop now wait while the 
> body of an exchange is read, also when it comes from a slow stream. The 
> upgrade guide entry of CAMEL-26539 is extended to timestamp grouping.
> _Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to