Redian新闻
>
文献求助2篇,谢谢~~~
avatar
文献求助2篇,谢谢~~~# ChemEng - 化学工程
u*y
1
小时候有一个说法,猪来穷,够来富,猫猫来了戴孝布。意思是猫跟着你走的话不好,一直以为只是一个流传下来的说法而已。可是今年一月,我爷爷病重住院,一天晚上十二点过,我从医院回家,一只猫从我们下车了一直跟着我走,吓它也不走,走了好远,还想跟着我上楼进家,吓得我赶紧把它拦在外面,真的是走了好远,就是那种有意识地跟着。那天晚上我就很不安,很害怕,第二天,我爷爷走了。有知道原因的吗?
avatar
s*r
2
I am fixing a bug in a project. The existing way to handle the case is
described as below.
There are 2 threads, one uploads(ftp) an image to the file server, the other
thread persist other relative data into the database.
Bug: if ftp image process fails, the new data still is stored into the db,
or if the data is rolled back, the image is still transferred to the file
server.
It is obvious not correct, either of them fails, all fails.
Difficulty: since here are using 2 threads, each is responsible of doing its
separate process so that the whole job is not treated as a unit of work.
I don't think this is a proper design in terms of this work flow.
I wonder the feasibility of making this 2 process all fails or all succeed
in multi-threading environment. If it is feasible, does any one have any
idea of making 2 processes as an unit of work?
Thanks.
avatar
w*r
3
作者(author):
Thomas Wellinger, Christof Pflumm, Jing Becker, Thomas Weimann, Mariano
Campoy-Quiles, Paul N. Stavrinou, Ulrich Scherf, and Donal D. C. Bradley
题目(title):
1.Blue-light-emitting polymer lasers with non-periodic circular Bragg
resonators
2.Lower limit of the lasing threshold in an organic microcavity
期刊名,年份,卷(期),起止页码:
Proc. SPIE 6999, 699907 (2008)
Proc. SPIE 6999, 69990X (2008)
链接
http://spie.org/x648.xml?product_id=781138
http://spie.org/x648.xml?product_id=781033
求助者联系方式(email):
wq
avatar
w*n
4
完全瞎扯。
avatar
g*g
5
It's a bad design to use 2 theads here. The main problem though,
is not that you can't sync between 2 theads, but that upload file
takes a long time while a DB transaction typically is short, it doesn't
make sense to wait until upload is finished to commit the transaction.
Of course if you can still use a compensation transaction to undo
previous transaction. But I don't see why you can't just put them
all in one thread, do upload first, then do db transaction, if upload
fails, throw an exception, if db transaction fails, throw an exception,
catch the exception and delete the partial file if it's there.

other
its

【在 s********r 的大作中提到】
: I am fixing a bug in a project. The existing way to handle the case is
: described as below.
: There are 2 threads, one uploads(ftp) an image to the file server, the other
: thread persist other relative data into the database.
: Bug: if ftp image process fails, the new data still is stored into the db,
: or if the data is rolled back, the image is still transferred to the file
: server.
: It is obvious not correct, either of them fails, all fails.
: Difficulty: since here are using 2 threads, each is responsible of doing its
: separate process so that the whole job is not treated as a unit of work.

avatar
l*1
6
Agree the above. Be an educated man and get rid of those junk rumors!
avatar
t*e
7
Compensation transaction is the last thing you want to do.
avatar
l*8
8
多虑了,如果他去世前你碰巧遇到狗,你也可以说是狗给你带来厄运

,一直以为只是一个流传下来的说法而已。可是今年一月,我爷爷病重住院,一天晚上
十二点过,我从医院回家,一只猫从我们下车了一直跟着我走,吓它也不走,走了好远
,还想跟着我上楼进家,吓得我赶紧把它拦在外面,真的是走了好远,就是那种

【在 u*****y 的大作中提到】
: 小时候有一个说法,猪来穷,够来富,猫猫来了戴孝布。意思是猫跟着你走的话不好,一直以为只是一个流传下来的说法而已。可是今年一月,我爷爷病重住院,一天晚上十二点过,我从医院回家,一只猫从我们下车了一直跟着我走,吓它也不走,走了好远,还想跟着我上楼进家,吓得我赶紧把它拦在外面,真的是走了好远,就是那种有意识地跟着。那天晚上我就很不安,很害怕,第二天,我爷爷走了。有知道原因的吗?
avatar
s*r
9
Thanks goodbug for your idea.
I completely agree with you that using one thread to handle the two
processes is the right design.
For some whatever reason, I have to follow the existing bad implementation :
(
Have good Friday.

【在 g*****g 的大作中提到】
: It's a bad design to use 2 theads here. The main problem though,
: is not that you can't sync between 2 theads, but that upload file
: takes a long time while a DB transaction typically is short, it doesn't
: make sense to wait until upload is finished to commit the transaction.
: Of course if you can still use a compensation transaction to undo
: previous transaction. But I don't see why you can't just put them
: all in one thread, do upload first, then do db transaction, if upload
: fails, throw an exception, if db transaction fails, throw an exception,
: catch the exception and delete the partial file if it's there.
:

avatar
s*r
10
Thank you for the idea.

【在 t*******e 的大作中提到】
: Compensation transaction is the last thing you want to do.
avatar
m*r
11
you can have have the file transfer thread wait for the db thread to finish,
and then continue to write the file, and roll back if file transfer fails.
since the db job should be fast, this might not be as bad as it sounds.

other
its

【在 s********r 的大作中提到】
: I am fixing a bug in a project. The existing way to handle the case is
: described as below.
: There are 2 threads, one uploads(ftp) an image to the file server, the other
: thread persist other relative data into the database.
: Bug: if ftp image process fails, the new data still is stored into the db,
: or if the data is rolled back, the image is still transferred to the file
: server.
: It is obvious not correct, either of them fails, all fails.
: Difficulty: since here are using 2 threads, each is responsible of doing its
: separate process so that the whole job is not treated as a unit of work.

avatar
u*d
12
这就是 two-phase commit
看看你的 application
如果对性能影响不大,还是全部 serialize 比较容易实现

other
its

【在 s********r 的大作中提到】
: I am fixing a bug in a project. The existing way to handle the case is
: described as below.
: There are 2 threads, one uploads(ftp) an image to the file server, the other
: thread persist other relative data into the database.
: Bug: if ftp image process fails, the new data still is stored into the db,
: or if the data is rolled back, the image is still transferred to the file
: server.
: It is obvious not correct, either of them fails, all fails.
: Difficulty: since here are using 2 threads, each is responsible of doing its
: separate process so that the whole job is not treated as a unit of work.

avatar
g*g
13
If you don't commit immediately, you may run out of DB threads while
waiting for file upload. It's worse than compensation transaction.

finish,

【在 m****r 的大作中提到】
: you can have have the file transfer thread wait for the db thread to finish,
: and then continue to write the file, and roll back if file transfer fails.
: since the db job should be fast, this might not be as bad as it sounds.
:
: other
: its

avatar
m*r
14
sorry. didn't mean "roll back". first thread need to commit right away.
and the second thread need to undo the commit.

【在 g*****g 的大作中提到】
: If you don't commit immediately, you may run out of DB threads while
: waiting for file upload. It's worse than compensation transaction.
:
: finish,

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。