Project

General

Profile

« Previous | Next » 

Revision 55330

Found bug of missing timestamp. When completing an incremental transaction, the whole record must be copied, not only the id ad body field.

View differences:

modules/cnr-mongo-mdstore/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/mongodb/MDStoreTransactionManagerImpl.java
662 662
		final MongoCollection<DBObject> mdstore = db.getCollection(currentId, DBObject.class);
663 663
		final FindIterable<DBObject> it = transaction.find().noCursorTimeout(true);
664 664
		for (DBObject currentObj : it) {
665

  
666
			BasicDBObject newObj = new BasicDBObject();
667

  
668 665
			final String id = (String) currentObj.get("id");
669
			final String body = (String) currentObj.get("body");
670
			newObj.put("id", id);
671
			newObj.put("body", body);
672
			if (StringUtils.isNotBlank(id)) {
673
				//setting to journaled write concern to be sure that when the write returns everything has been flushed to disk (https://docs.mongodb.org/manual/faq/developers/#when-does-mongodb-write-updates-to-disk)
674
				//the explicit fsync command can't be run anymore: 'Command failed with error 13: 'fsync may only be run against the admin database.'
675
				final MongoCollection<DBObject> mdstoreWrite = mdstore.withWriteConcern(WriteConcern.JOURNALED);
676
				mdstoreWrite.replaceOne(new BasicDBObject("id", id), newObj, new UpdateOptions().upsert(true));
677
			}
666
			//setting to journaled write concern to be sure that when the write returns everything has been flushed to disk (https://docs.mongodb.org/manual/faq/developers/#when-does-mongodb-write-updates-to-disk)
667
			//the explicit fsync command can't be run anymore: 'Command failed with error 13: 'fsync may only be run against the admin database.'
668
			final MongoCollection<DBObject> mdstoreWrite = mdstore.withWriteConcern(WriteConcern.JOURNALED);
669
			mdstoreWrite.replaceOne(new BasicDBObject("id", id), currentObj, new UpdateOptions().upsert(true));
678 670
		}
679 671
	}
680 672

  

Also available in: Unified diff