cannot rebuild unique index, but cannot find offending duplicate records
Hi,
running the standard version of OrientDB v2.2.3 currently on a single Ubuntu 14.04 LTS server with 128GB installed RAM, I have a database "cdrarch", with class "@mds_csv_cf14" with all STRING properties except one DATETIME property which is named "START_DATETIME".
Initially (no records in this class yet) I defined a unique index "idx_mds_csv_cf14_0" on the combination of [ START_DATETIME, FILENAME, RECORD_NUMBER ] : CREATE INDEX idx_mds_csv_cf14_0 ON mds_csv_cf14 (START_DATETIME, FILENAME, RECORD_NUMBER) UNIQUE
So far so good, then I started loading records into the class during 2 weeks. Currently there is about 70M records in this table.
For some reasons, the Java process of the OrientDB was leaking (?) or at least growing terribly in consumed memory (see below log extract), so that it finally became inaccessible from a data-loading client program (via REST-api), console, or web interface.
2016-07-18 09:50:02:610 INFO Database 'OSystem' uses 101,525MB/119,482MB of DISKCACHE memory, while Heap is not completely used (usedHeap=272 6MB maxHeap=7282MB). To improve performance set maxHeap to 3271MB and DISKCACHE to 123492MB [OAbstractProfiler$MemoryChecker] 2016-07-18 09:50:02:611 INFO -> Open server.sh (or server.bat on Windows) and change the following variables: 1) MAXHEAP=-Xmx3271M 2) MAXDISK CACHE=123492 [OAbstractProfiler$MemoryChecker] 2016-07-18 09:50:02:612 INFO Database 'cdrarch' uses 101,525MB/119,482MB of DISKCACHE memory, while Heap is not completely used (usedHeap=272 6MB maxHeap=7282MB). To improve performance set maxHeap to 3271MB and DISKCACHE to 123492MB [OAbstractProfiler$MemoryChecker] 2016-07-18 09:50:02:612 INFO -> Open server.sh (or server.bat on Windows) and change the following variables: 1) MAXHEAP=-Xmx3271M 2) MAXDISK CACHE=123492 [OAbstractProfiler$MemoryChecker]
Had to stop the server process to unblock it.
I found that the "server.sh" script did not have any explicit setting for "MAXDISKCACHE", which -according to certain articles on the web- might have led to this growing Java process.
So I gave that parameter the following value: MAXDISKCACHE="-Dstorage.diskCache.bufferSize=8192" then restarted the server program.
Then I restarted the data-loading program which is attempting to insert new records into "@mds_csv_cf14".
But somehow the unique index got corrupted, because loading new records into this class fails with the message
2016-07-19 12:07:07:160 SEVER Internal server error: com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot index record #218:1248232: found duplicated key 'OCompositeKey{keys=[Thu Jun 30 23:52:57 CEST 2016, C22N010000000014.001.00665346, 1]}' in index 'idx_mds_csv_cf14_0' previously assigned to the record #214:1248231
When I search for duplicate records in the class for the combination of the unique index, i.e. [ START_DATETIME, FILENAME, RECORD_NUMBER ], around the timestamp indicated in the log message (Jun 30 23:52:57 CEST 2016), there aren't any :
SELECT * FROM ( SELECT START_DATETIME, FILENAME, RECORD_NUMBER, count(*) AS cnt FROM mds_csv_cf14 WHERE START_DATETIME BETWEEN DATE('20160630','yyyyMMdd') AND DATE('20160701','yyyyMMdd') GROUP BY START_DATETIME, FILENAME, RECORD_NUMBER ) WHERE cnt > 1
=> no records returned from this query
So, again based on articles on the web describing that the index sometimes contains data which is not referring to anything really in the class, I dropped the index, and started it re-creation.
This failed again on exactly the same spot :
2016-07-19 12:07:07:160 SEVER Internal server error: com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot index record #218:1248232: found duplicated key 'OCompositeKey{keys=[Thu Jun 30 23:52:57 CEST 2016, C22N010000000014.001.00665346, 1]}' in index 'idx_mds_csv_cf14_0' previously assigned to the record #214:1248231 DB name="cdrarch"INDEX=idx_mds_csv_cf14_0 RID=#214:1248231
=> there are no duplicate records found from the "GROUP BY" query earlier, but according to the index-creating there would be duplicates anyhow ??!!
Steps to reproduce the problem
Remove the setting for MAXDISKCACHE in the "server.sh" file, and start stuffing tons of records to the database. Hopefully this reproduces the problem. I won't try it, because it risks my database to become even more corrupted.
OrientDB Version
v2.2.3
Operating System
Ubuntu 14.04
Java Version
1.8.0_92
Hi @rdelangh Did you try to fetch both records by id, I mean #218:1248232 and #214:1248231 ?
hi laa , thx for your quick reply. I queried for #218:1248232 , and it was found after 22 minutes only (?!!) with SELECT FROM mds_csv_cf14 WHERE @rid = #218:1248232
Its START_DATETIME is "30/06/2016 23:52:57", FILENAME is "C22N010000000014.001.00665346" and RECORD_NUMBER is "1"
Doing the same for the other RID #214:1248231 , returns no results.
@rdelangh what is your database size, is it possible to share it ?
hi laa, it's about 54GB now, so I guess it's not feasible to share it unless I send you some HDD... ;-)
@rdelangh could you not only drop index but double check that files with the same names droped from disk ?
I deleted that record with @rid = #218:1248232, now busy re-creating the index. It's at 25% now, still busy. There are two index files, if the index rebuild fails again then I will remove these files first and retry the index rebuild :
ls -ltr idx_mds_csv_cf14_0*
-rw-r--r-- 1 root root 1024 Jul 19 16:13 idx_mds_csv_cf14_0.nbt -rw-r--r-- 1 root root 2465793024 Jul 19 16:43 idx_mds_csv_cf14_0.sbt
hi laa , thx for your quick reply. I queried for #218:1248232 , and it was found after 22 minutes only (?!!) with SELECT FROM mds_csv_cf14 WHERE @rid = #218:1248232
The reason it took so long is because you are querying it as if RID is a field; trying using SELECT FROM #218:1248232 it should be significantly faster
@rdelangh any updates? Btw I do not recommend you to setup such small about of memory as 8GB with 128 GB memory 100 GB disk cache is completely OK. About of desynchronization of records and index, after force-kill of the server that is possible because you, I suppose, work in nontx mode. In this mode, updates of indexes and records are not atomic, and I do suggest you to work on tx mode.
hi laa,
Current status: there were still a few other records that blocked the creation of the unique index, but I managed to remove them one by one, and now the index is recreated. I started loading the records again, that's still functioning fine now. Had to increase the disk-cache from 16GB to 32GB in order to get some decent speed for that records-loading (decreased from 5msec/record to 0.6msec/record).
About your remarks/queries:
- the query on RID : ok, didn't find that in the documentation ... will use that syntax from now on.
- the memory settings: I found a little bit of documentation about how the heap and disk cache can be set, but no recommendation on their values or how one relates to the other (heap not too big, I read; but how big is "not too big" ?)
- I find in the docs some config params for "tx", but only one that refers to "atomic" operations: "tx.trackAtomicOperations" (but: "This setting is used only for debug purpose...") -> which setting are you suggesting and where it its documentation?
thanks a lot so far for your help !
I searched the web, and found the "txMode" for 'index durability' ; I assume this is what you are referring at ? It currently is (and has always been) on FULL, apparently :
config ... |69 |index.txMode |FULL
From the OrientDB docs: "Indicates the index durability level in TX mode. Can be ROLLBACK_ONLY or FULL (ROLLBACK_ONLY by default).."
but I never gave it any value, so the default seems to be FULL, in contrary to what the documentation says.
And so, with this setting, we got anyhow indexes that do not correspond to what the class contains...
Hi @rdelangh no , that is not that mode :-). Did you start transaction when you made changes ? I mean did you did call db.begin() , db.commit() ?
ok ;-) No, not doing explicit BEGIN...COMMIT transactions because I send (via REST-API) a single INSERT statement of a few 100's records at a time, assuming that this is considered by OrientDB as a single, auto-committing statement.
@rdelangh no it is not So when you killed server some of the records changed/written, but indexes are not changed. About disk cache size I do suggest you to set it at least to 100GB to get excellent performance.
I am issuing a REST batch command, using the JSON syntax { "transaction": true , "operations": [ (the few 100's of INSERTs) ] }
So according to the documentation of OrientDB (http://orientdb.com/new-sql-command-batch/ and others) this JSON has to be sent to the "/batch" URL, and that is exactly what I am doing.
So despite all that, it seems that inconsistencies can happen between the records in the class and its index(es) when the dbase engine (is not killed by myself manually, but) did hang due to OOM...
-> a bug ?
hm we need to double check that.
@maggiolo00 could you double check that ?
@laa sure let me check!
@laa yes with batch api and transaction : true the TX is started automatically and committed at the end
@rdelangh and you use only given rest API with transaction:true and nothing more ?
btw @rdelangh could you update to 2.2.5 version ?