Topic: 一個有趣的問題。

  Print this page

1.一個有趣的問題。 Copy to clipboard
Posted by: skwujinhua
Posted on: 2008-11-20 09:26

今天測試出程序一個有趣的問題﹕

程序中調用一個Oracle已存儲過程:Insert_log()﹐寫入一條記錄到數據庫中﹐該操作需要700MS的樣子﹐我同時調用該過程二次(如下)﹐但是數據庫中只有一條記錄﹐且程序不報錯。

代碼﹕Link_NTPServer.Insert_log();
Link_NTPServer.Insert_log();

后來我做這樣的處理﹕
Link_NTPServer.Insert_log();
Thread.sleep(1000);
Link_NTPServer.Insert_log();

這樣就有二條記錄了。
這程序只是單線程﹐應該在第一次調用的時候完成寫入記錄才執行第二次調用。怎么會出現未執行完就執行第二次調用的情況呢?

請各位GG JJ多多指教。

2.Re:一個有趣的問題。 [Re: skwujinhua] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2008-11-22 01:11

I'm not a database expert, neither have I worked on any Oracle database. This looks like a particular feature that Oracle has to prevent data overflowing. But I am not sure. Try to run a test on another database implementation would reveal my guess.

As you mentioned yourself, the insertion will take about 700 ms, hence in the course of the second insertion, the first insertion had not finished yet. Whereas if you wait 1 second, the first insertion has finished for sure.

Thus, I think maybe it is because of this Link_NTPServer.Insert_log();


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923