Project

General

Profile

Bug #7367

disable TriggerTracker for TemporaryBuffer

Added by Constantin Asofiei 12 months ago. Updated 10 months ago.

Status:
Closed
Priority:
Normal
Target version:
-
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:
version:

History

#1 Updated by Constantin Asofiei 12 months ago

A session trigger can't be registered for a temp-table (I also double-checked in OE). This means that RecordBuffer.triggerTracker should have no meaning for a record in a temp-table. I've tried disabling it in RecordBuffer.setCurrentRecord, via:

Index: src/com/goldencode/p2j/persist/RecordBuffer.java
===================================================================
--- 7156a/src/com/goldencode/p2j/persist/RecordBuffer.java    (revision 4090)
+++ 7156a/src/com/goldencode/p2j/persist/RecordBuffer.java    (working copy)

@@ -11552,8 +11574,11 @@
             Record oldRecord = this.currentRecord;
             this.currentRecord = newCrtRecord;

-            TriggerTracker.releaseTracker(oldRecord);
-            this.triggerTracker = TriggerTracker.getTracker(this.currentRecord, dmoBufInterface, bufferManager);
+            if (!isTemporary())
+            {
+               TriggerTracker.releaseTracker(oldRecord);
+               this.triggerTracker = TriggerTracker.getTracker(this.currentRecord, dmoBufInterface, bufferManager);
+            }

             updateNoUndoState();

@@ -11574,8 +11599,11 @@
          this.undoable.checkUndoable(true);
       }

-      TriggerTracker.releaseTracker(currentRecord);
-      this.triggerTracker = TriggerTracker.getTracker(newCrtRecord, dmoBufInterface, bufferManager);
+      if (!isTemporary())
+      {
+         TriggerTracker.releaseTracker(currentRecord);
+         this.triggerTracker = TriggerTracker.getTracker(newCrtRecord, dmoBufInterface, bufferManager);
+      }

       this.currentRecord = newCrtRecord;
       this.recordChanged = false; // invalidate CURRENT-CHANGED flag (see above)

But this causes regressions.

Is there some state in TriggerTracker which is not related to invoking session or schema triggers?

#2 Updated by Alexandru Lungu 12 months ago

I recall seeing ASSIGN trigger checks for when we were executing copy-temp-table (fast or not). I don't know if they were in fact useless or not, but I know such checks are in place :)
I will take a look.

#3 Updated by Alexandru Lungu 12 months ago

In setCurrentRecord, there is the following condition (line 11422):

targetBuffer.getTriggerTracker() != null &&
!targetBuffer.getTriggerTracker().isExecuting(DatabaseEventType.WRITE, currentRecord.primaryKey())

If this condition is true, doFlush = true; may execute.
  • Before your change, this could happen (the trigger tracker is not null and no DatabaseEventType.WRITE is executing)
  • After your change, this can't ever happen because the trigger tracker is always null

It seems to me that this should have been:

targetBuffer.getTriggerTracker() == null ||
!targetBuffer.getTriggerTracker().isExecuting(DatabaseEventType.WRITE, currentRecord.primaryKey())

instead. Note that there are two such conditionals there.

The same goes for RecordNursery.makeVisible.

#4 Updated by Ovidiu Maxiniuc 12 months ago

Alex,
I do not think that is the good condition. If targetBuffer.getTriggerTracker() is null then the second operand of || is evaluated and a NPE will be thrown.

#5 Updated by Ovidiu Maxiniuc 12 months ago

Ovidiu Maxiniuc wrote:

Alex,
I do not think that is the good condition. If targetBuffer.getTriggerTracker() is null then the second operand of || is evaluated and a NPE will be thrown.

Sorry, you are right, I did not see you changed the != into ==, not only && into ||.

#6 Updated by Alexandru Lungu 12 months ago

Ovidiu Maxiniuc wrote:

Sorry, you are right, I did not see you changed the != into ==, not only && into ||.

Hmm, I edited my comment to use == null seconds after posting :) Sorry for the inconvenience

#7 Updated by Ovidiu Maxiniuc 12 months ago

Alexandru Lungu wrote:

Hmm, I edited my comment to use == null seconds after posting :)

That make sense. I reviewed the small piece of code from the email notification in Thunderbird. Only after clicking submit I noticed the ==.

Sorry for the inconvenience

No problem 👍. It happened to me as well.

Back to our code. The change looks fine, but the two conditionals must be adapted. The doFlush will be always true for temp-tables. Also armCurrentChanged(); probably should not be called since FIND CURRENT is meaningless in this case since (no external change since the _temp database is context private).

#8 Updated by Alexandru Lungu 12 months ago

Ovidiu Maxiniuc wrote:

Back to our code. The change looks fine, but the two conditionals must be adapted. The doFlush will be always true for temp-tables. Also armCurrentChanged(); probably should not be called since FIND CURRENT is meaningless in this case since (no external change since the _temp database is context private).

I see your point. However, I think triggerTracker is null only when currentRecord is null. In all of the previous changes, before reaching !targetBuffer.getTriggerTracker().isExecuting, .isAvailable or .getRecord() == null is checked. This means that doFlush was true only if the currentRecord was set, which implicitly meant that the trigger tracker was set.

#9 Updated by Alexandru Lungu 12 months ago

Radu, can you do the changes from #7367-1 and #7367-3 over 7026d and do an in-depth testing of a large customer application? I want to know if we can integrate this easily and fast or there are still obvious regressions to handle.

#10 Updated by Radu Apetrii 12 months ago

Alexandru Lungu wrote:

Radu, can you do the changes from #7367-1 and #7367-3 over 7026d and do an in-depth testing of a large customer application? I want to know if we can integrate this easily and fast or there are still obvious regressions to handle.

On it. I will get back with updates as quickly as possible.

#11 Updated by Radu Apetrii 12 months ago

I've done some in-depth testing with a large customer application and I could not find any regression(s).
Since the changes were already on my computer, I committed them to 7026d, rev. 14578.

#12 Updated by Alexandru Lungu 12 months ago

  • Status changed from New to WIP
  • % Done changed from 0 to 100

This reached 7156a. 7026d was rebased. Testing passed.

#13 Updated by Alexandru Lungu 12 months ago

  • Status changed from WIP to Review

#14 Updated by Alexandru Lungu 12 months ago

  • Status changed from Review to Test

Merged 7026d to trunk as rev. 14587.

#15 Updated by Ovidiu Maxiniuc 12 months ago

Alexandru Lungu wrote:

Merged 7026d to trunk as rev. 14587.

That makes sense. I attempted to do a review of the 7026d branch on Friday evening but it was nowhere to be found. :)

#16 Updated by Alexandru Lungu 10 months ago

  • Assignee set to Alexandru Lungu

This can be closed.

#17 Updated by Greg Shah 10 months ago

  • Status changed from Test to Closed

Also available in: Atom PDF