Skip to content

Commit 44bfee6

Browse files
Issue orientechnologies#2150 try to hide record if delete is broken.
1 parent 473c281 commit 44bfee6

23 files changed

Lines changed: 28 additions & 551 deletions

File tree

client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -613,78 +613,6 @@ public OStorageOperationResult<Boolean> deleteRecord(final ORecordId iRid, final
613613
} while (true);
614614
}
615615

616-
@Override
617-
public OStorageOperationResult<Boolean> hideRecord(ORecordId iRecordId, ORecordVersion iVersion, int iMode,
618-
ORecordCallback<Boolean> iCallback) {
619-
checkConnection();
620-
621-
if (iMode == 1 && iCallback == null)
622-
// ASYNCHRONOUS MODE NO ANSWER
623-
iMode = 2;
624-
625-
OChannelBinaryAsynchClient network = null;
626-
do {
627-
try {
628-
network = beginRequest(OChannelBinaryProtocol.REQUEST_RECORD_HIDE);
629-
return new OStorageOperationResult<Boolean>(hideRecord(iRecordId, iVersion, iMode, iCallback, network));
630-
} catch (OModificationOperationProhibitedException mope) {
631-
handleDBFreeze();
632-
} catch (Exception e) {
633-
handleException(network, "Error on delete record " + iRecordId, e);
634-
635-
}
636-
} while (true);
637-
}
638-
639-
private boolean hideRecord(final ORecordId iRid, ORecordVersion iVersion, int iMode, final ORecordCallback<Boolean> iCallback,
640-
final OChannelBinaryAsynchClient network) throws IOException {
641-
try {
642-
643-
network.writeRID(iRid);
644-
network.writeVersion(iVersion);
645-
network.writeByte((byte) iMode);
646-
647-
} finally {
648-
endRequest(network);
649-
}
650-
651-
switch (iMode) {
652-
case 0:
653-
// SYNCHRONOUS
654-
try {
655-
beginResponse(network);
656-
return network.readByte() == 1;
657-
} finally {
658-
endResponse(network);
659-
}
660-
661-
case 1:
662-
// ASYNCHRONOUS
663-
if (iCallback != null) {
664-
final int sessionId = getSessionId();
665-
Callable<Object> response = new Callable<Object>() {
666-
public Object call() throws Exception {
667-
Boolean result;
668-
669-
try {
670-
OStorageRemoteThreadLocal.INSTANCE.get().sessionId = sessionId;
671-
beginResponse(network);
672-
result = network.readByte() == 1;
673-
} finally {
674-
endResponse(network);
675-
OStorageRemoteThreadLocal.INSTANCE.get().sessionId = -1;
676-
}
677-
678-
iCallback.call(iRid, result);
679-
return null;
680-
}
681-
};
682-
asynchExecutor.submit(new FutureTask<Object>(response));
683-
}
684-
}
685-
return false;
686-
}
687-
688616
@Override
689617
public boolean cleanOutRecord(ORecordId recordId, ORecordVersion recordVersion, int iMode, ORecordCallback<Boolean> callback) {
690618
checkConnection();

client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemoteThread.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,7 @@ public OStorageOperationResult<Boolean> deleteRecord(final ORecordId iRid, final
270270
}
271271
}
272272

273-
@Override
274-
public OStorageOperationResult<Boolean> hideRecord(ORecordId iRecordId, ORecordVersion iVersion, int iMode,
275-
ORecordCallback<Boolean> iCallback) {
276-
pushSession();
277-
try {
278-
return delegate.hideRecord(iRecordId, iVersion, iMode, iCallback);
279-
} finally {
280-
popSession();
281-
}
282-
}
273+
283274

284275
@Override
285276
public boolean updateReplica(int dataSegmentId, ORecordId rid, byte[] content, ORecordVersion recordVersion, byte recordType)

core/src/main/java/com/orientechnologies/orient/core/db/ODatabaseComplex.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -267,27 +267,7 @@ public <RET extends T> RET save(T iObject, String iClusterName, OPERATION_MODE i
267267
*/
268268
public ODatabaseComplex<T> delete(ORID iRID, ORecordVersion iVersion);
269269

270-
/**
271-
* Hides records content by putting tombstone on the records position but does not delete record itself.
272-
*
273-
* This method is used in case of record content itself is broken and can not be read or deleted. So it is emergence method. This
274-
* method can be used only if there is no active transaction in database.
275-
*
276-
* @param rid
277-
* record id.
278-
* @param version
279-
* record version.
280-
* @throws java.lang.UnsupportedOperationException
281-
* In case current version of cluster does not support given operation.
282-
* @throws com.orientechnologies.orient.core.exception.ORecordNotFoundException
283-
* if record is already deleted/hidden.
284-
* @throws com.orientechnologies.orient.core.exception.OConcurrentModificationException
285-
* If provided record version is not latest.
286-
*
287-
* @return Current db instance.
288-
*/
289270

290-
public ODatabaseComplex<T> hide(ORID rid, ORecordVersion version);
291271

292272
public ODatabaseComplex<T> cleanOutRecord(ORID rid, ORecordVersion version);
293273

core/src/main/java/com/orientechnologies/orient/core/db/ODatabaseRecordWrapperAbstract.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,6 @@ public ODatabaseComplex<ORecordInternal<?>> delete(final ORID iRid, final ORecor
207207
return this;
208208
}
209209

210-
@Override
211-
public ODatabaseComplex<ORecordInternal<?>> hide(ORID rid, ORecordVersion version) {
212-
underlying.hide(rid, version);
213-
return this;
214-
}
215-
216210
@Override
217211
public ODatabaseComplex<ORecordInternal<?>> cleanOutRecord(ORID rid, ORecordVersion version) {
218212
underlying.cleanOutRecord(rid, version);

core/src/main/java/com/orientechnologies/orient/core/db/raw/ODatabaseRaw.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -317,21 +317,6 @@ public OStorageOperationResult<Boolean> delete(final ORecordId iRid, final OReco
317317
}
318318
}
319319

320-
public OStorageOperationResult<Boolean> hide(final ORecordId iRid, final ORecordVersion iVersion, final boolean iRequired,
321-
final int iMode) {
322-
try {
323-
final OStorageOperationResult<Boolean> result = storage.hideRecord(iRid, iVersion, iMode, null);
324-
if (!result.getResult() && iRequired)
325-
throw new ORecordNotFoundException("The record with id " + iRid + " was not found");
326-
return result;
327-
} catch (OException e) {
328-
// PASS THROUGH
329-
throw e;
330-
} catch (Exception e) {
331-
OLogManager.instance().exception("Error on deleting record " + iRid, e, ODatabaseException.class);
332-
return new OStorageOperationResult<Boolean>(Boolean.FALSE);
333-
}
334-
}
335320

336321
public boolean cleanOutRecord(final ORecordId iRid, final ORecordVersion iVersion, final boolean iRequired, final int iMode) {
337322
try {

core/src/main/java/com/orientechnologies/orient/core/db/record/ODatabaseRecordAbstract.java

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -592,12 +592,6 @@ public ODatabaseComplex<ORecordInternal<?>> delete(final ORID iRecord, final ORe
592592
return this;
593593
}
594594

595-
@Override
596-
public ODatabaseComplex<ORecordInternal<?>> hide(ORID rid, ORecordVersion version) {
597-
executeHideRecord(rid, version, true, true, OPERATION_MODE.SYNCHRONOUS);
598-
return this;
599-
}
600-
601595
public ODatabaseComplex<ORecordInternal<?>> cleanOutRecord(final ORID iRecord, final ORecordVersion iVersion) {
602596
executeDeleteRecord(iRecord, iVersion, true, true, OPERATION_MODE.SYNCHRONOUS, true);
603597
return this;
@@ -1147,71 +1141,6 @@ else if (rec != null)
11471141
}
11481142
}
11491143

1150-
public void executeHideRecord(OIdentifiable record, final ORecordVersion iVersion, final boolean iRequired,
1151-
boolean iCallTriggers, final OPERATION_MODE iMode) {
1152-
checkOpeness();
1153-
final ORecordId rid = (ORecordId) record.getIdentity();
1154-
1155-
if (rid == null)
1156-
throw new ODatabaseException(
1157-
"Cannot hide record because it has no identity. Probably was created from scratch or contains projections of fields rather than a full record");
1158-
1159-
if (!rid.isValid())
1160-
return;
1161-
1162-
checkSecurity(ODatabaseSecurityResources.CLUSTER, ORole.PERMISSION_DELETE, getClusterNameById(rid.clusterId));
1163-
1164-
final Set<OIndex<?>> lockedIndexes = new HashSet<OIndex<?>>();
1165-
setCurrentDatabaseinThreadLocal();
1166-
ORecordSerializationContext.pushContext();
1167-
try {
1168-
record = record.getRecord();
1169-
if (record instanceof ODocument)
1170-
acquireIndexModificationLock((ODocument) record, lockedIndexes);
1171-
1172-
try {
1173-
// if cache is switched off record will be unreachable after delete.
1174-
ORecord<?> rec = record.getRecord();
1175-
if (iCallTriggers && rec != null)
1176-
callbackHooks(TYPE.BEFORE_DELETE, rec);
1177-
1178-
// CHECK IF ENABLE THE MVCC OR BYPASS IT
1179-
final ORecordVersion realVersion = mvcc ? iVersion : OVersionFactory.instance().createUntrackedVersion();
1180-
1181-
final OStorageOperationResult<Boolean> operationResult;
1182-
try {
1183-
operationResult = underlying.hide(rid, realVersion, iRequired, (byte) iMode.ordinal());
1184-
1185-
if (iCallTriggers) {
1186-
if (!operationResult.isMoved() && rec != null)
1187-
callbackHooks(TYPE.AFTER_DELETE, rec);
1188-
else if (rec != null)
1189-
callbackHooks(TYPE.DELETE_REPLICATED, rec);
1190-
}
1191-
} catch (Throwable t) {
1192-
if (iCallTriggers)
1193-
callbackHooks(TYPE.DELETE_FAILED, rec);
1194-
throw t;
1195-
}
1196-
1197-
// REMOVE THE RECORD FROM 1 AND 2 LEVEL CACHES
1198-
if (!operationResult.isMoved()) {
1199-
getLevel1Cache().deleteRecord(rid);
1200-
}
1201-
1202-
} catch (OException e) {
1203-
// RE-THROW THE EXCEPTION
1204-
throw e;
1205-
1206-
} catch (Throwable t) {
1207-
// WRAP IT AS ODATABASE EXCEPTION
1208-
throw new ODatabaseException("Error on deleting record in cluster #" + record.getIdentity().getClusterId(), t);
1209-
}
1210-
} finally {
1211-
releaseIndexModificationLock(lockedIndexes);
1212-
ORecordSerializationContext.pullContext();
1213-
}
1214-
}
12151144

12161145
@Override
12171146
public ODatabaseComplex<?> getDatabaseOwner() {

core/src/main/java/com/orientechnologies/orient/core/db/record/ODatabaseRecordTx.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,6 @@ public ODatabaseRecord delete(final ORecordInternal<?> iRecord) {
350350
return this;
351351
}
352352

353-
@Override
354-
public ODatabaseComplex<ORecordInternal<?>> hide(ORID rid, ORecordVersion version) {
355-
if (currentTx.isActive())
356-
throw new ODatabaseException("This operation can be executed only in non tx mode");
357-
358-
return super.hide(rid, version);
359-
}
360353

361354
@Override
362355
public ODatabaseRecord delete(final ORecordInternal<?> iRecord, final OPERATION_MODE iMode) {

core/src/main/java/com/orientechnologies/orient/core/record/ORecord.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -199,22 +199,7 @@ public interface ORecord<T> extends ORecordElement, OIdentifiable, Serializable
199199
*/
200200
public <RET extends ORecord<T>> RET delete();
201201

202-
/**
203-
* Hides records content by putting tombstone on the records position but does not delete record itself.
204-
*
205-
* This method is used in case of record content itself is broken and can not be read or deleted. So it is emergence method. This
206-
* method can be used only if there is no active transaction in database.
207-
*
208-
* @throws java.lang.UnsupportedOperationException
209-
* In case current version of cluster does not support given operation.
210-
* @throws com.orientechnologies.orient.core.exception.ORecordNotFoundException
211-
* if record is already deleted/hidden.
212-
* @throws com.orientechnologies.orient.core.exception.OConcurrentModificationException
213-
* If record version is not latest.
214-
*
215-
* @return Hidden record instance.
216-
*/
217-
public <RET extends ORecord<T>> RET hide();
202+
218203

219204
/**
220205
* Fills the record parsing the content in JSON format.

core/src/main/java/com/orientechnologies/orient/core/record/ORecordAbstract.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,6 @@ public ORecordAbstract<T> delete() {
340340
return this;
341341
}
342342

343-
@Override
344-
public ORecordAbstract<T> hide() {
345-
getDatabase().hide(getIdentity(), getRecordVersion());
346-
setDirty();
347-
return this;
348-
}
349-
350343
public int getSize() {
351344
return _size;
352345
}

core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLHide.java

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)