You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by happen <37...@qq.com> on 2020/08/18 12:39:54 UTC

racing risk in MultiTxn's serialize

Hi


&nbsp; &nbsp; &nbsp;I think may be there is a little risk when running MultiTxn's serialize txns.get(vidx1) step. Because probably the txns' size is changing that time in the future.


```
public void serialize(OutputArchive a_, String tag) throws java.io.IOException {
&nbsp; a_.startRecord(this,tag);
&nbsp; {
&nbsp; &nbsp; a_.startVector(txns,"txns");
&nbsp; &nbsp; if (txns!= null) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int len1 = txns.size();
&nbsp; &nbsp; &nbsp; &nbsp; for(int vidx1 = 0; vidx1<len1; vidx1++) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Txn e1 = (Txn) txns.get(vidx1);
&nbsp; a_.writeRecord(e1,"e1");
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; }
&nbsp; &nbsp; a_.endVector(txns,"txns");
&nbsp; }
&nbsp; a_.endRecord(this,tag);
}
```

Re: racing risk in MultiTxn's serialize

Posted by Ted Dunning <te...@gmail.com>.
Hey there,

THanks for your email, but could you format your messages without HTML?  It
is very hard to read and understand what you are saying otherwise.



On Tue, Aug 18, 2020 at 10:27 AM happen <37...@qq.com> wrote:

> Hi
>
>
> &nbsp; &nbsp; &nbsp;I think may be there is a little risk when running
> MultiTxn's serialize txns.get(vidx1) step. Because probably the txns' size
> is changing that time in the future.
>
>
> ```
> public void serialize(OutputArchive a_, String tag) throws
> java.io.IOException {
> &nbsp; a_.startRecord(this,tag);
> &nbsp; {
> &nbsp; &nbsp; a_.startVector(txns,"txns");
> &nbsp; &nbsp; if (txns!= null) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int
> len1 = txns.size();
> &nbsp; &nbsp; &nbsp; &nbsp; for(int vidx1 = 0; vidx1<len1; vidx1++) {
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Txn e1 = (Txn) txns.get(vidx1);
> &nbsp; a_.writeRecord(e1,"e1");
> &nbsp; &nbsp; &nbsp; &nbsp; }
> &nbsp; &nbsp; }
> &nbsp; &nbsp; a_.endVector(txns,"txns");
> &nbsp; }
> &nbsp; a_.endRecord(this,tag);
> }
> ```

Re: racing risk in MultiTxn's serialize

Posted by Ted Dunning <te...@gmail.com>.
No significant changes should ever be made to any transaction as it passes
through the pipeline.

The code you point out is the creation of the multi. The mutation is in the
same block that created it and no references escape before the endVector
call is made.

I request again. Can you please stop sending messages with embedded HTML?



On Wed, Aug 19, 2020 at 12:18 AM happen <37...@qq.com> wrote:

> I found that&nbsp; one observer's SyncRequestProcessor is appending
> one&nbsp; MultiTxn's log, FinalRequestProcessor access MultiTxn's at the
> same time. maybe MultiTxn will be modified by FinalRequestProcessor&nbsp;
> in the future.
>
>
> It already was when I modified zk server to be a tool dealing txn
> logs.&nbsp;
>
>
> ------------------&nbsp;原始邮件&nbsp;------------------
> 发件人:
>                                                   "dev"
>                                                                 <
> ted.dunning@gmail.com&gt;;
> 发送时间:&nbsp;2020年8月19日(星期三) 凌晨1:44
> 收件人:&nbsp;"dev"<dev@zookeeper.apache.org&gt;;
>
> 主题:&nbsp;Re: racing risk in MultiTxn's serialize
>
>
>
> Why do you think that this code is a problem? The instance in question is
> limited to a single thread.
>
>
>
> On Tue, Aug 18, 2020 at 10:27 AM happen <370119764@qq.com&gt; wrote:
>
> &gt; Hi
> &gt;
> &gt;
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;I think may be there is a little risk
> when running
> &gt; MultiTxn's serialize txns.get(vidx1) step. Because probably the txns'
> size
> &gt; is changing that time in the future.
> &gt;
> &gt;
> &gt; ```
> &gt; public void serialize(OutputArchive a_, String tag) throws
> &gt; java.io.IOException {
> &gt; &amp;nbsp; a_.startRecord(this,tag);
> &gt; &amp;nbsp; {
> &gt; &amp;nbsp; &amp;nbsp; a_.startVector(txns,"txns");
> &gt; &amp;nbsp; &amp;nbsp; if (txns!= null) {&amp;nbsp; &amp;nbsp;
> &amp;nbsp; &amp;nbsp; &amp;nbsp; int
> &gt; len1 = txns.size();
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(int vidx1 = 0;
> vidx1<len1; vidx1++) {
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Txn e1 = (Txn)
> txns.get(vidx1);
> &gt; &amp;nbsp; a_.writeRecord(e1,"e1");
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
> &gt; &amp;nbsp; &amp;nbsp; }
> &gt; &amp;nbsp; &amp;nbsp; a_.endVector(txns,"txns");
> &gt; &amp;nbsp; }
> &gt; &amp;nbsp; a_.endRecord(this,tag);
> &gt; }
> &gt; ```

Re: racing risk in MultiTxn's serialize

Posted by happen <37...@qq.com>.
I found that&nbsp; one observer's SyncRequestProcessor is appending one&nbsp; MultiTxn's log, FinalRequestProcessor access MultiTxn's at the same time. maybe MultiTxn will be modified by FinalRequestProcessor&nbsp; in the future.


It already was when I modified zk server to be a tool dealing txn logs.





------------------ &gt;&nbsp; ------------------


from:                                                                                                                        "dev"                                                                                    <ted.dunning@gmail.com&gt;;
time:&nbsp;2020-08-19(Wed) 01:44
to:&nbsp;"dev"<dev@zookeeper.apache.org&gt;;

theme:&nbsp;Re: racing risk in MultiTxn's serialize



Why do you think that this code is a problem? The instance in question is
limited to a single thread.



On Tue, Aug 18, 2020 at 10:27 AM happen <370119764@qq.com&gt; wrote:

&gt; Hi
&gt;
&gt;
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;I think may be there is a little risk when running
&gt; MultiTxn's serialize txns.get(vidx1) step. Because probably the txns' size
&gt; is changing that time in the future.
&gt;
&gt;
&gt; ```
&gt; public void serialize(OutputArchive a_, String tag) throws
&gt; java.io.IOException {
&gt; &amp;nbsp; a_.startRecord(this,tag);
&gt; &amp;nbsp; {
&gt; &amp;nbsp; &amp;nbsp; a_.startVector(txns,"txns");
&gt; &amp;nbsp; &amp;nbsp; if (txns!= null) {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int
&gt; len1 = txns.size();
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(int vidx1 = 0; vidx1<len1; vidx1++) {
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Txn e1 = (Txn) txns.get(vidx1);
&gt; &amp;nbsp; a_.writeRecord(e1,"e1");
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&gt; &amp;nbsp; &amp;nbsp; }
&gt; &amp;nbsp; &amp;nbsp; a_.endVector(txns,"txns");
&gt; &amp;nbsp; }
&gt; &amp;nbsp; a_.endRecord(this,tag);
&gt; }
&gt; ```

回复: racing risk in MultiTxn's serialize

Posted by happen <37...@qq.com>.
I found that&nbsp; one observer's SyncRequestProcessor is appending one&nbsp; MultiTxn's log, FinalRequestProcessor access MultiTxn's at the same time. maybe MultiTxn will be modified by FinalRequestProcessor&nbsp; in the future.


It already was when I modified zk server to be a tool dealing txn logs.&nbsp;


------------------&nbsp;原始邮件&nbsp;------------------
发件人:                                                                                                                        "dev"                                                                                    <ted.dunning@gmail.com&gt;;
发送时间:&nbsp;2020年8月19日(星期三) 凌晨1:44
收件人:&nbsp;"dev"<dev@zookeeper.apache.org&gt;;

主题:&nbsp;Re: racing risk in MultiTxn's serialize



Why do you think that this code is a problem? The instance in question is
limited to a single thread.



On Tue, Aug 18, 2020 at 10:27 AM happen <370119764@qq.com&gt; wrote:

&gt; Hi
&gt;
&gt;
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;I think may be there is a little risk when running
&gt; MultiTxn's serialize txns.get(vidx1) step. Because probably the txns' size
&gt; is changing that time in the future.
&gt;
&gt;
&gt; ```
&gt; public void serialize(OutputArchive a_, String tag) throws
&gt; java.io.IOException {
&gt; &amp;nbsp; a_.startRecord(this,tag);
&gt; &amp;nbsp; {
&gt; &amp;nbsp; &amp;nbsp; a_.startVector(txns,"txns");
&gt; &amp;nbsp; &amp;nbsp; if (txns!= null) {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int
&gt; len1 = txns.size();
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(int vidx1 = 0; vidx1<len1; vidx1++) {
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Txn e1 = (Txn) txns.get(vidx1);
&gt; &amp;nbsp; a_.writeRecord(e1,"e1");
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&gt; &amp;nbsp; &amp;nbsp; }
&gt; &amp;nbsp; &amp;nbsp; a_.endVector(txns,"txns");
&gt; &amp;nbsp; }
&gt; &amp;nbsp; a_.endRecord(this,tag);
&gt; }
&gt; ```

Re: racing risk in MultiTxn's serialize

Posted by Ted Dunning <te...@gmail.com>.
Why do you think that this code is a problem? The instance in question is
limited to a single thread.



On Tue, Aug 18, 2020 at 10:27 AM happen <37...@qq.com> wrote:

> Hi
>
>
> &nbsp; &nbsp; &nbsp;I think may be there is a little risk when running
> MultiTxn's serialize txns.get(vidx1) step. Because probably the txns' size
> is changing that time in the future.
>
>
> ```
> public void serialize(OutputArchive a_, String tag) throws
> java.io.IOException {
> &nbsp; a_.startRecord(this,tag);
> &nbsp; {
> &nbsp; &nbsp; a_.startVector(txns,"txns");
> &nbsp; &nbsp; if (txns!= null) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int
> len1 = txns.size();
> &nbsp; &nbsp; &nbsp; &nbsp; for(int vidx1 = 0; vidx1<len1; vidx1++) {
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Txn e1 = (Txn) txns.get(vidx1);
> &nbsp; a_.writeRecord(e1,"e1");
> &nbsp; &nbsp; &nbsp; &nbsp; }
> &nbsp; &nbsp; }
> &nbsp; &nbsp; a_.endVector(txns,"txns");
> &nbsp; }
> &nbsp; a_.endRecord(this,tag);
> }
> ```