Bug #10195
Reset of query buffer in a nested function
100%
History
#1 Updated by Eduard Soltan about 1 year ago
Found a problem in unit tests of a customer application.
def var dec1 as decimal.
define buffer bbook for book.
function myFunc returns logical (buffer bbook for book):
message bbook.f1.
return yes.
end.
for each book:
delete book.
end.
for each table2:
delete table2.
end.
create bbook.
bbook.f1 = 'abc'.
release bbook.
create table2.
table2.f1 = 'abc'.
table2.f2 = 3.
release table2.
create table2.
table2.f1 = 'abc'.
table2.f2 = 4.
release table2.
for each bbook, each table2 where table2.f1 = bbook.f1:
myFunc (buffer bbook).
end.
It happens at second iteration.
While processing finalizable in of the myFunc function, iterateReleaseOverrideScope of bbook is reset to -1.
While setting the next iteration of for-each block in TM.iterateWorker, it will incorrectly release bbook buffer.
#3 Updated by Eduard Soltan about 1 year ago
I think this tests is a bit more accurate.
def var dec1 as decimal.
define buffer bbook for book.
function myFunc returns logical (buffer bbook for book):
message bbook.f1.
return yes.
end.
for each bbook, each table2 where table2.f1 = bbook.f1:
myFunc (buffer bbook).
end.
In this way we open the scope of the bbook in for-each block, but also in myFunc function.
While processing the finalizables of myFunc, it will reset the iterateReleaseOverrideScope of the bbook. But I think it is not correct, since it also have a scope open at previous level.
I think that we should verify iterateReleaseOverrideScope to be equal to current scope before resetting it in RB.finishedImpl.
int currentScope = bufferManager.getOpenBufferScopes();
if (currentScope == iterateReleaseOverrideScope)
{
// Reset iterate release override scope.
iterateReleaseOverrideScope = -1;
}
#4 Updated by Eduard Soltan about 1 year ago
- % Done changed from 0 to 100
Committed on 10195a, rev. 15996.
#5 Updated by Eduard Soltan about 1 year ago
- Status changed from New to WIP
#6 Updated by Eduard Soltan about 1 year ago
- Status changed from WIP to Review
- reviewer Alexandru Lungu added
#7 Updated by Alexandru Lungu about 1 year ago
Eduard, it will take me a bit more time to review, so I may not make it by EOD. I need to get some tests ongoing on OE to get myself accustomed with the scenario.
#8 Updated by Alexandru Lungu about 1 year ago
- Assignee set to Eduard Soltan
- Status changed from Review to Internal Test
I am OK with the changes in 10195a.
The point here is that the buffer can have its scope opened several times. Using it as an argument buffer will forcefully open its scope again, so when the finalizables are processed, it incorrectly resets iterateReleaseOverrideScope. It should have reset that only when finalizing the right scope, but not a nested scope.
You can proceed with testing on 10195a, but I wonder if there is an overall bug with iterateReleaseOverrideScope. What if the buffer is used as an outer component two times (nested)? Shouldn't the iterateReleaseOverrideScope be a stack of scopes instead? Please make a test with this.
You can test 10195a and if everything is OK - merge. But I would like to have #10195 opened to figure out if iterateReleaseOverrideScope is indeed broken and shall be improved. We can do this in a "b" branch with lower priority.
#9 Updated by Eduard Soltan about 1 year ago
Alexandru Lungu wrote:
I am OK with the changes in 10195a.
The point here is that the buffer can have its scope opened several times. Using it as an argument buffer will forcefully open its scope again, so when the finalizables are processed, it incorrectly resets
iterateReleaseOverrideScope. It should have reset that only when finalizing the right scope, but not a nested scope.You can proceed with testing on 10195a, but I wonder if there is an overall bug with
iterateReleaseOverrideScope. What if the buffer is used as an outer component two times (nested)? Shouldn't theiterateReleaseOverrideScopebe a stack of scopes instead? Please make a test with this.
I have created the following test:
function myFunc returns logical (buffer bbook for book):
for each bbook, each table2 where table2.f1 = bbook.f1:
message bbook.f1.
end.
return yes.
end.
for each bbook, each table2 where table2.f1 = bbook.f1:
myFunc (buffer bbook).
end.
It is not affected since the RecordBuffer will not be included in the of the nested for-each block or any other iteration block, it only be included in the finalizables of the function, procedure or method.
Also used compile test1.p listing command on the example, and this is the result:
File Name Line Blk. Type Tran Blk. Label
-------------------- ---- ----------- ---- --------------------------------
...e18\test1\test1.p 27 Function No Function myFunc
Buffers: mydb12.bbook
...e18\test1\test1.p 28 For No
...e18\test1\test1.p 0 Procedure No
Buffers: mydb12.table2
...e18\test1\test1.p 34 For No
Buffers: mydb12.bbook
#10 Updated by Alexandru Lungu about 1 year ago
It is not affected since the RecordBuffer will not be included in the of the nested for-each block or any other iteration block, it only be included in the finalizables of the function, procedure or method.
Isn't the nested for each setting iterateReleaseOverrideScope on 2 (because the buffer is opened twice once in the outer-scope and once inside the internal procedure)? So when myFunc ends, it will get out-of-scope, finalizable is called and the flag reset?
#11 Updated by Eduard Soltan about 1 year ago
Alexandru Lungu wrote:
It is not affected since the RecordBuffer will not be included in the of the nested for-each block or any other iteration block, it only be included in the finalizables of the function, procedure or method.
Isn't the nested for each setting
iterateReleaseOverrideScopeon 2 (because the buffer is opened twice once in the outer-scope and once inside the internal procedure)? So whenmyFuncends, it will get out-of-scope, finalizable is called and the flag reset?
Actually yes, this is exactly what happens. Somehow the overall behaviour of the test in fwd matches that in OE, but when taking a closer look iterateReleaseOverrideScope is resetting at myFunc completion.
#12 Updated by Alexandru Lungu about 1 year ago
Eduard Soltan wrote:
Alexandru Lungu wrote:
It is not affected since the RecordBuffer will not be included in the of the nested for-each block or any other iteration block, it only be included in the finalizables of the function, procedure or method.
Isn't the nested for each setting
iterateReleaseOverrideScopeon 2 (because the buffer is opened twice once in the outer-scope and once inside the internal procedure)? So whenmyFuncends, it will get out-of-scope, finalizable is called and the flag reset?Actually yes, this is exactly what happens. Somehow the overall behaviour of the test in fwd matches that in OE, but when taking a closer look
iterateReleaseOverrideScopeis resetting atmyFunccompletion.
This is a problem, right?
#13 Updated by Eduard Soltan about 1 year ago
Alexandru Lungu wrote:
This is a problem, right?
Of course this is a problem, I am currently giving a try to the idea of making the iterateReleaseOverrideScope flag as a stack.
#14 Updated by Eduard Soltan about 1 year ago
Committed on 10195a, rev. 15997.
Changed iterateReleaseOverrideScope into a stack of scopes. A new level is added to the stack in disableReleaseOnIterate when the RB is part of CompoundQuery, and poped from the stack when the scope ends.
#15 Updated by Eduard Soltan about 1 year ago
- Status changed from Internal Test to Review
#16 Updated by Alexandru Lungu about 1 year ago
- Status changed from Review to Internal Test
I am OK with the changes in 10195a.
#17 Updated by Eduard Soltan about 1 year ago
Testing performed the 10195 branch:
- smoke tests of a GUI application ☑️
- smoke and unit tests of a large GUI application ☑️
- chui regression testing ☑️
- fwd and unit tests ☑️
- harness ☑️
#18 Updated by Constantin Asofiei about 1 year ago
I'll run ETF today.
#19 Updated by Constantin Asofiei about 1 year ago
Constantin Asofiei wrote:
I'll run ETF today.
ETF passed.
#20 Updated by Constantin Asofiei about 1 year ago
- Status changed from Internal Test to Merge Pending
#21 Updated by Eduard Soltan about 1 year ago
- Status changed from Merge Pending to Test
10195a was merged to trunk 16024 and archived.