6

We have noticed some strange behavior in our production data concerning the GUIDs we are storing from a .Net DataSet into an Oracle RAW column.

We have the following set up:

  • Table A has a RAW column Id
  • Table B has an RAW column ResponsibleObjectId

The ResponsibleObjectId column is filled with the ID of table A when it is created in function of Table A (not always the case, so there is no FK on the column).

This happens in our .Net server layer. The two tables are in 2 separate DataSets. These 2 datasets are then saved to an oracle DB (11g).

Most of the times this works, but in a few cases (like 1/10.000.000 rows) the resulting guids are not entirely the same:

ResponsibleObjectId                 ID
665B8FFDE5A04163A96D96A25702665B    665B8FFDE5A04163A96D96A257023065
325C8AB000434503B8D2F980B33B325C    325C8AB000434503B8D2F980B33B4B58
AF831B5207E04D2ABE0E3ADAC802AF83    AF831B5207E04D2ABE0E3ADAC8023FA1
88DD5AF244DC4EA08075DB53CA1988DD    88DD5AF244DC4EA08075DB53CA19072E
75A5E5111DEE4021BA6EB016178775A5    75A5E5111DEE4021BA6EB01617876E66

They match, expect for the last 4 characters.

We save the GUIDs using a stored procedure as follows:

.Net DAL

OracleCommand cmdSpInsert = (OracleCommand)database.GetStoredProcCommand("PKG_TableB.InsertTableB");
database.AddInParameter(cmdSpInsert, "PAR_ResponsibleObjectId", DbType.StringFixedLength, 36, "ResponsibleObjectId", DataRowVersion.Current);

Oracle SP

PROCEDURE InsertTableB
(
    ...
    PAR_ResponsibleObjectId IN CHAR,
    ...
)
IS BEGIN
    INSERT INTO StockMov
           (
                ...
                HEXTORAW(REPLACE(UPPER(PAR_ResponsibleObjectId), '-','')),
                ...
           );
END InsertTableB;

We have no idea what is causing this strange behavior. We've seen it happen in one similar case on 2 different columns in our Table A as well, so it does not seem related specifically to table B.

If any extra information is needed, please ask and I'll update the question.

Any help is greatly appreciated in solving our mystery! :)

Edit As asked in the comments, the assignment of the ResponsibleObjectId column very simple, like this:

dataSetB.ResponsibleObjectId = dataSetA.Id

Also the two datasets are saved in the same transaction.

4

2 回答 2

3

byte[] idGuid = Guid.NewGuid().ToByteArray();

数据集A.Id = idGuid;

dataSetB.ResponsibleObjectId = idGuid;

/* 不要做 dataSetB.ResponsibleObjectId = dataSetA.Id

不要进行任何数据类型转换 - 保持二进制/原始 */

于 2012-12-05T14:43:08.243 回答
0

我们有一些非常强烈的迹象表明这些问题的发生是因为他们的数据库设置不符合我们的要求。oracle 数据库没有在专用机器上运行,并且没有足够的内存。

在很多情况下,这些事件可能与其 RAC 上的问题相匹配。

我们现在将尝试说服客户升级他们的数据库服务器。

于 2013-03-21T09:40:23.967 回答