New behavior cause data corruption in v11

View: New views
20 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 - 3 - 4 | Next >

New behavior cause data corruption in v11

by Alan Chan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We all know that data corruption happens pretty often in v11. Tracking
down the reproducible steps is one thing and finding its cause is another.
For the past week, we have been tracking hard on a reproducible data
corruption and eventually found its cause.

4D now supports mutlipe CPUs on Trigger. Different invoking table maintain
its own context in server. So far, it works great until same invoking
table query a record that has the same Record Number of a freshly deleted
record. In such case, you will get wrong query result. Picture the
followings.

1) Create a new recod with unique primary key in One Table A.
2) Create a new record in Many Table B.
3) Delete the newly created record in Many Table B
4) Delete the newly created record in On Table A
5) Create a new record with new unique primary key in One Table A. Mark
down the record number (this new record will be given the same record
number as the deleted record in step 4) by 4D and this is normal).
6) Create a new record in Many Table B. This will cause the problem.

In the trigger on step 6), Query([Table A];[Table A]PrimaryKey=[Table
B]ForeignKey) will get the record deleted in step 4.


C_string(20;$OldPrimary;$NewPrimary;$NewForeignKey)
C_boolean($matchPrimaryKey)

$OldPrimary:=[Table A]PrimaryKey `in debugger in trigger, you would see
record content of old deteled record of Table A. It has the same record
number of the newly created record but still have the old PrimaryKey
$NewForeignKey:=Table B]ForeignKey
Query([Table A];[Table A]PrimaryKey=[Table B]ForeignKey) `this query
doesn't work
if((records in selection([Table A])=1)
$matchPrimarykey:=Table A]PrimaryKe=Table B]ForeignKey `this would return
false although it should be true (pls note that the record is not
corrupted at this stage
Save record([Table A]) `Saving this record would corrupt the data and the
saved record will have the old primarykey instead of new primary key.
end if

Please note that it would happen only

1) the invoking table is the same. In this case, it's Table B.
2) the invoking table did call Table A in trigger (Table A content would
remain in trigger memory)
3) the newly create record of Table A called in the Table B trigger
happens to have same record number of deteled record and already remain in
the trigger memory.

Alan Chan

**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: New behavior cause data corruption in v11

by Chip Scheide :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

is all this happening inside a transaction??

it is the only way that it makes sense that a deleted record is found
by a query


On Wed, 11 Nov 2009 06:13:47 +0800, Alan Chan wrote:

> We all know that data corruption happens pretty often in v11. Tracking
> down the reproducible steps is one thing and finding its cause is another.
> For the past week, we have been tracking hard on a reproducible data
> corruption and eventually found its cause.
>
> 4D now supports mutlipe CPUs on Trigger. Different invoking table maintain
> its own context in server. So far, it works great until same invoking
> table query a record that has the same Record Number of a freshly deleted
> record. In such case, you will get wrong query result. Picture the
> followings.
>
> 1) Create a new recod with unique primary key in One Table A.
> 2) Create a new record in Many Table B.
> 3) Delete the newly created record in Many Table B
> 4) Delete the newly created record in On Table A
> 5) Create a new record with new unique primary key in One Table A. Mark
> down the record number (this new record will be given the same record
> number as the deleted record in step 4) by 4D and this is normal).
> 6) Create a new record in Many Table B. This will cause the problem.
>
> In the trigger on step 6), Query([Table A];[Table A]PrimaryKey=[Table
> B]ForeignKey) will get the record deleted in step 4.
>
>
> C_string(20;$OldPrimary;$NewPrimary;$NewForeignKey)
> C_boolean($matchPrimaryKey)
>
> $OldPrimary:=[Table A]PrimaryKey `in debugger in trigger, you would see
> record content of old deteled record of Table A. It has the same record
> number of the newly created record but still have the old PrimaryKey
> $NewForeignKey:=Table B]ForeignKey
> Query([Table A];[Table A]PrimaryKey=[Table B]ForeignKey) `this query
> doesn't work
> if((records in selection([Table A])=1)
> $matchPrimarykey:=Table A]PrimaryKe=Table B]ForeignKey `this would return
> false although it should be true (pls note that the record is not
> corrupted at this stage
> Save record([Table A]) `Saving this record would corrupt the data and the
> saved record will have the old primarykey instead of new primary key.
> end if
>
> Please note that it would happen only
>
> 1) the invoking table is the same. In this case, it's Table B.
> 2) the invoking table did call Table A in trigger (Table A content would
> remain in trigger memory)
> 3) the newly create record of Table A called in the Table B trigger
> happens to have same record number of deteled record and already remain in
> the trigger memory.
>
> Alan Chan
>
> **********************************************************************
> Get the speed and power of 4D v11 SQL
> before upgrade prices increase - http://www.4d.com
>    
>
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4D.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4D_Tech-Unsubscribe@...
> **********************************************************************
>
**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Parent Message unknown RE: New behavior cause data corruption in v11

by Thomas Fitch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alan,

I just set up a test database running 11.4 HF7 in a client/server
environment. Here is my setup:

Table_1 (1 field)
prikey (unique alpha field)

Table_2 (1 field)
fkey (alpha field)

Many to one relation from fkey to prikey, Automatic relation turned on.

Code in the Table_2 trigger:

Case of

  : (Database event=On Saving New Record Event )

    TRACE

    C_STRING(20;$OldPrimary;$NewPrimary;$NewForeignKey)

    C_BOOLEAN($matchPrimaryKey)
               
    $OldPrimary:=[Table_1]prikey  

    $NewForeignKey:=[Table_2]fkey

    QUERY([Table_1];[Table_1]prikey=[Table_2]fkey)  `*

    If ((Records in selection([Table_1])=1))

      $matchPrimarykey:=[Table_1]prikey=[Table_2]fkey  `**

      SAVE RECORD([Table_1]) 

    End if
               
End case

Test case that I ran:

1. create some records in Table_1
2. create some matching records in Table_2 (1 many record per one record)
3. delete one of the early records in Table_2
4. delete the corresponding "one" record in Table_1
5. create a new record in Table_1
6. create a new record in Table_2

At step 6 I TRACE through the code and see two interesting things:
-At the location in code above where I have one * the query works and I get
the expected record in Table_1.
-At the location in code above where I have two *'s the value returned is
True as expected.

After all this I ran a Verify on the records and indexes and came back with
no corruption.

Am I doing something wrong in trying to reproduce this issue?

Kind Regards,

Tom Fitch
Technical Services Team Member
4D, Inc.

**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com


4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Parent Message unknown RE: New behavior cause data corruption in v11

by Thomas Fitch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alan,

A couple oversights in my last post:

1. I meant to let you know that I have the "On Saving New Record" trigger on
for Table_1.
2. The other kind of corruption you mean (saving an old prikey instead of
the newly created prikey) is also not occurring. Because the QUERY works
correctly the right prikey value is saved, so there's none of the non-MSC
find-able corruption.

Kind Regards,

Tom Fitch
Technical Services Team Member
4D, Inc.

**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: New behavior cause data corruption in v11

by Peter Jakobsson-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 10 Nov 2009, at 23:33, Chip Scheide wrote:

> it is the only way that it makes sense that a deleted record is found
> by a query


In that case, the query result and the record properties (when  
accessed by the language) should still agree, but in Alan's account  
they don't appear to.

if((records in selection([Table A])=1)  <-- this was returning true,  
which is consistent with the query finding the new record

... but . . .

$matchPrimarykey:=Table A]PrimaryKe=Table B]ForeignKey <-- this was  
returning false which is consistent with the language accessing the  
old record

Maybe the query is finding the record but not loading it and the old  
one remains in cache.

Just my interpretation - Thomas says he can't reproduce it so maybe  
it's not what it seems. Also, Alan, what do you mean by . . .

> Query([Table A];[Table A]PrimaryKey=[Table B]ForeignKey) `this query
> doesn't work

  . . . i.e.

[A] - does the query not return any records when it should or
[B] - it returns [records in selection([Table A])=1)] but it's the  
wrong record (this was my interpretation of your description)

Regards

Peter


**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Parent Message unknown RE: New behavior cause data corruption in v11

by Jesse Pina :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alan,

Regarding this point:

> 4D now supports mutlipe CPUs on Trigger.

Just to clarify, this is not a correct statement.  Triggers run in the
cooperative process.  All 4D code runs in the cooperative thread regardless
of where it is run (project method, trigger, form method, ...).

At this year's Summit, Josh Fletcher covered the topic of threads and the
new threading model in his preclass "4D Server v11 SQL: Understanding
Performance".  So if you attended the Summit this year, I would recommend
looking at his session notes, there is a lot of great detail in there.

Kind regards,

--
Jesse Piña
Technical Services Team Member
4D, Inc.
**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com


4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: New behavior cause data corruption in v11

by Alan Chan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, it is inside transaction and trigger.

Please note that the deleted record is in a comleted transaction and was
found in another transaction inside the trigger.

Alan Chan

4D iNug Technical <4d_tech@...> writes:

>is all this happening inside a transaction??
>
>it is the only way that it makes sense that a deleted record is found
>by a query
>
>
>On Wed, 11 Nov 2009 06:13:47 +0800, Alan Chan wrote:
>> We all know that data corruption happens pretty often in v11. Tracking
>> down the reproducible steps is one thing and finding its cause is
>another.
>> For the past week, we have been tracking hard on a reproducible data
>> corruption and eventually found its cause.
>>
>> 4D now supports mutlipe CPUs on Trigger. Different invoking table
>maintain
>> its own context in server. So far, it works great until same invoking
>> table query a record that has the same Record Number of a freshly
>deleted
>> record. In such case, you will get wrong query result. Picture the
>> followings.
>>
>> 1) Create a new recod with unique primary key in One Table A.
>> 2) Create a new record in Many Table B.
>> 3) Delete the newly created record in Many Table B
>> 4) Delete the newly created record in On Table A
>> 5) Create a new record with new unique primary key in One Table A. Mark
>> down the record number (this new record will be given the same record
>> number as the deleted record in step 4) by 4D and this is normal).
>> 6) Create a new record in Many Table B. This will cause the problem.
>>
>> In the trigger on step 6), Query([Table A];[Table A]PrimaryKey=[Table
>> B]ForeignKey) will get the record deleted in step 4.
>>
>>
>> C_string(20;$OldPrimary;$NewPrimary;$NewForeignKey)
>> C_boolean($matchPrimaryKey)
>>
>> $OldPrimary:=[Table A]PrimaryKey `in debugger in trigger, you would see
>> record content of old deteled record of Table A. It has the same record
>> number of the newly created record but still have the old PrimaryKey
>> $NewForeignKey:=Table B]ForeignKey
>> Query([Table A];[Table A]PrimaryKey=[Table B]ForeignKey) `this query
>> doesn't work
>> if((records in selection([Table A])=1)
>> $matchPrimarykey:=Table A]PrimaryKe=Table B]ForeignKey `this would
>return
>> false although it should be true (pls note that the record is not
>> corrupted at this stage
>> Save record([Table A]) `Saving this record would corrupt the data and
>the
>> saved record will have the old primarykey instead of new primary key.
>> end if
>>
>> Please note that it would happen only
>>
>> 1) the invoking table is the same. In this case, it's Table B.
>> 2) the invoking table did call Table A in trigger (Table A content would
>> remain in trigger memory)
>> 3) the newly create record of Table A called in the Table B trigger
>> happens to have same record number of deteled record and already remain
>in
>> the trigger memory.
>>
>> Alan Chan
>>
>> **********************************************************************
>> Get the speed and power of 4D v11 SQL
>> before upgrade prices increase - http://www.4d.com
>>    
>>
>> 4D Internet Users Group (4D iNUG)
>> FAQ:  http://lists.4d.com/faqnug.html
>> Archive:  http://lists.4D.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub:  mailto:4D_Tech-Unsubscribe@...
>> **********************************************************************
>>
>**********************************************************************
>Get the speed and power of 4D v11 SQL
>before upgrade prices increase - http://www.4d.com
>  
>
>4D Internet Users Group (4D iNUG)
>FAQ:  http://lists.4d.com/faqnug.html
>Archive:  http://lists.4D.com/archives.html
>Options: https://lists.4d.com/mailman/options/4d_tech
>Unsub:  mailto:4D_Tech-Unsubscribe@...
>**********************************************************************


**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: New behavior cause data corruption in v11

by Alan Chan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

4D iNug Technical <4d_tech@...> writes:
>Many to one relation from fkey to prikey, Automatic relation turned on.

Like many old timer 4D developers, I never turned on Automatic relation on
data entry except in some special reporting.

Alan Chan

**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: New behavior cause data corruption in v11

by Alan Chan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

4D iNug Technical <4d_tech@...> writes:
>Hi Alan,
>
>A couple oversights in my last post:
>
>1. I meant to let you know that I have the "On Saving New Record" trigger
>on
>for Table_1.

Exactly as I did.
>
>2. The other kind of corruption you mean (saving an old prikey instead of
>the newly created prikey) is also not occurring. Because the QUERY works
>correctly the right prikey value is saved, so there's none of the non-MSC
>find-able corruption.

If your query works, then no corruption should be happened. The most
important part is the "Record Number". Query will always work if the newly
created record has different record number from the deleted record. As you
know, 4D will use old Record Number. The same record number is the key.
That's why we spent more than a week of 3 developers' time to track this
down.

Same record number aside, the deleted record must be already in the memory
of the trigger. That means, the invoking table should have access the
"pre-deleted record" in the trigger. Then this pre-deleted record would
remain in its trigger memory even after it's completed. Once the record is
deleted and new record created, use the previous invoking table to access
the new record while the old deleted record was still in Trigger's memory,
if you put trace in beginning of the trigger, you will see the old deleted
record was still there with old Primiary key but same record as the new
one. Do query at this time in the trigger, the query won't work.

Please note that if the invoking table access other primary record before
they access the newly created record, the problem won't happen.

Alan Chan
>
>

**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: New behavior cause data corruption in v11

by Alan Chan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jesse,

It's interesting. As far as I know, triggers from different tables could
be executed across CPUs. This information was obtained from 4D official.
Please correct me, if all triggers are still running on one single CPU and
only SQL access more than one CPU like the initial stage of v11,
converting to v11 might not be top priority for us. It also meant that
having dual quad core or even more powerful machine won't do any good
unless we switch everything to SQL which is unlikely.

I heard that 4D v11.4 has changed this from the first version of v11, but
again, different 4D official would provide different information.

Alan Chan

4D iNug Technical <4d_tech@...> writes:
>Just to clarify, this is not a correct statement.  Triggers run in the
>cooperative process.  All 4D code runs in the cooperative thread
>regardless
>of where it is run (project method, trigger, form method, ...).
>
>At this year's Summit, Josh Fletcher covered the topic of threads and the
>new threading model in his preclass "4D Server v11 SQL: Understanding
>Performance".  So if you attended the Summit this year, I would recommend
>looking at his session notes, there is a lot of great detail in there.

**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: New behavior cause data corruption in v11

by David Dancy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Alan,

I think I've got this straight in my head. Let me see if I can get it
out in words:

At this point (AFAIK) triggers only run on one CPU/core on the server.

The only change to the triggers mechanism in v11 from v2004 is that a
trigger now no longer blocks access to the whole database. It only
blocks access to the table it's running in, so you can have multiple
triggers running at the same time, provided that they are for
different tables.

The triggers are all 4D language, which means that they execute in the
cooperative thread maintained by the server on the client's behalf.
Each client has a cooperative thread and a pre-emptive thread. The
cooperative thread runs inside the 4D process, which means it's tied
to one CPU/core. The OS may shift it to a different CPU/core, but the
point is it's only running on one CPU/core at a time, and all the
cooperative threads together run in the same CPU/core because they're
all in the same process. The pre-emptive thread (I believe) can attach
to any CPU/core. But since all triggers run in the cooperative thread
for their client, although you may have multiple triggers going at
once, they are all on the same CPU/core.

If a trigger issues a query, that is handled by the server's DB
engine, using as many threads as required. Since the DB engine threads
are all pre-emptive, they can attach to any CPU/core as the OS sees
fit. I think the trigger's cooperative thread will block until the
results come back from the DB engine.

Corrections/clarifications welcome.

HTH

David Dancy
Sydney, Australia



2009/11/11 Alan Chan <alan@...>:

> Jesse,
>
> It's interesting. As far as I know, triggers from different tables could
> be executed across CPUs. This information was obtained from 4D official.
> Please correct me, if all triggers are still running on one single CPU and
> only SQL access more than one CPU like the initial stage of v11,
> converting to v11 might not be top priority for us. It also meant that
> having dual quad core or even more powerful machine won't do any good
> unless we switch everything to SQL which is unlikely.
>
> I heard that 4D v11.4 has changed this from the first version of v11, but
> again, different 4D official would provide different information.
>
> Alan Chan
>
> 4D iNug Technical <4d_tech@...> writes:
>>Just to clarify, this is not a correct statement.  Triggers run in the
>>cooperative process.  All 4D code runs in the cooperative thread
>>regardless
>>of where it is run (project method, trigger, form method, ...).
>>
>>At this year's Summit, Josh Fletcher covered the topic of threads and the
>>new threading model in his preclass "4D Server v11 SQL: Understanding
>>Performance".  So if you attended the Summit this year, I would recommend
>>looking at his session notes, there is a lot of great detail in there.
>
**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com


4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: New behavior cause data corruption in v11

by Alan Chan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Thomas,

To reproduce the issue and minimize complication, you might want to
disable automatic relation and use simple query (not even using Relate
One). Also use simple Transaction and Trigger (no cascade
trigger/multi-level transaction). It means every step is done in one
single transaction/trigger and completed.

>1. create some records in Table_1
>2. create some matching records in Table_2 (1 many record per one record)
>3. delete one of the early records in Table_2
Did you delete exactly the record you just created in step 3)? Deleting
other many records that ralate to other One table would break the test.
>
>4. delete the corresponding "one" record in Table_1
>5. create a new record in Table_1
>6. create a new record in Table_2
On step 6, if you debug in trigger, you will see deleted record of Table_1
on debug window. This deleted record should contain old primarykey and
same Record Number (you could test its record number in the debug window)
before you do the query.

I hope this would help.

Alan Chan

**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: New behavior cause data corruption in v11

by Peter Schumacher-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm missing here one sentence....


Am 10.11.2009 um 17:16 schrieb Jesse Pina:

> At this year's Summit, Josh Fletcher covered the topic of threads  
> and the
> new threading model in his preclass "4D Server v11 SQL: Understanding
> Performance".  So if you attended the Summit this year, I would  
> recommend
> looking at his session notes, there is a lot of great detail in there.

Greetings,
[4D-Consulting.com]eK, Wiesbaden (Germany)
Peter Schumacher
--------------------------------------------------------
Web: http://www.4D-Consulting.com/
FreeCall:  0800-434 636 7
Tel.:      +49-611-9406.850 - Fax: +49-611-9406.744
4D-Consulting.com eK - Scharnhorststr. 36 - 65195 Wiesbaden
Member of the German Developer Network  http://www.die4dwerkstatt.de









**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: Does v11 support multiple CPUs for converted application?

by Jeffrey Kain :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

4D has always been really clear that anything running 4D code would not be
preemptively threaded. Originally, only queries were going to be
preemptively threaded, but this changed as we got close to the release of 4D
Server to include all database operations that do not involve the direct
execution of 4D code.

So, triggers, stored procedures, and code running in the web server can't
run on multiple CPUs. All other database operations that are made from
clients or other outside connections can all be preemptively threaded. And
yes, it makes a really big difference in performance in the real world. It's
not imaginary and it's not a trick.

Of course, if your system is 100% trigger/web server/stored procedure based,
you won't get this benefit, but the engine itself is also a lot faster than
v2004.

JEff

On 11/10/09 9:35 PM, "Alan Chan" <alan@...> wrote:

> Thanks for the detailed explanation. According to your understanding, how
> 4D did its demo on 24 cores and make a big deal out of its scalability.

**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Does v11 support multiple CPUs for converted application?

by Alan Chan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi David,

Thanks for the detailed explanation. According to your understanding, how
4D did its demo on 24 cores and make a big deal out of its scalability.
While some did challange how 4d did its 500 users demo, 4D insists that
they simulate real world practices like entering new orders and creates
reporting. Are they all done in SQL and not 4D languages like
trigger/transaction? How could real world data entry without
trigger/transaction for any mission critical application. If all new
entries are done in Trigger, 500 users are doing entries on "one" cpu??? I
think they could take lunch instead of coffee break after hitting the
enter key for a single order entry:-) I don't think that 4D assume their
developers rewritting their mature applications in SQL yet without
considering other SQL engines.

Any clarification would be greatly appreciated.

Alan Chan

4D iNug Technical <4d_tech@...> writes:

>Alan,
>
>I think I've got this straight in my head. Let me see if I can get it
>out in words:
>
>At this point (AFAIK) triggers only run on one CPU/core on the server.
>
>The only change to the triggers mechanism in v11 from v2004 is that a
>trigger now no longer blocks access to the whole database. It only
>blocks access to the table it's running in, so you can have multiple
>triggers running at the same time, provided that they are for
>different tables.
>
>The triggers are all 4D language, which means that they execute in the
>cooperative thread maintained by the server on the client's behalf.
>Each client has a cooperative thread and a pre-emptive thread. The
>cooperative thread runs inside the 4D process, which means it's tied
>to one CPU/core. The OS may shift it to a different CPU/core, but the
>point is it's only running on one CPU/core at a time, and all the
>cooperative threads together run in the same CPU/core because they're
>all in the same process. The pre-emptive thread (I believe) can attach
>to any CPU/core. But since all triggers run in the cooperative thread
>for their client, although you may have multiple triggers going at
>once, they are all on the same CPU/core.
>
>If a trigger issues a query, that is handled by the server's DB
>engine, using as many threads as required. Since the DB engine threads
>are all pre-emptive, they can attach to any CPU/core as the OS sees
>fit. I think the trigger's cooperative thread will block until the
>results come back from the DB engine.
>
>Corrections/clarifications welcome.
>
>HTH
>
>David Dancy
>Sydney, Australia
>
>
>
>2009/11/11 Alan Chan <alan@...>:
>> Jesse,
>>
>> It's interesting. As far as I know, triggers from different tables could
>> be executed across CPUs. This information was obtained from 4D official.
>> Please correct me, if all triggers are still running on one single CPU
>and
>> only SQL access more than one CPU like the initial stage of v11,
>> converting to v11 might not be top priority for us. It also meant that
>> having dual quad core or even more powerful machine won't do any good
>> unless we switch everything to SQL which is unlikely.
>>
>> I heard that 4D v11.4 has changed this from the first version of v11,
>but
>> again, different 4D official would provide different information.
>>
>> Alan Chan
>>
>> 4D iNug Technical <4d_tech@...> writes:
>>>Just to clarify, this is not a correct statement.  Triggers run in the
>>>cooperative process.  All 4D code runs in the cooperative thread
>>>regardless
>>>of where it is run (project method, trigger, form method, ...).
>>>
>>>At this year's Summit, Josh Fletcher covered the topic of threads and
>the
>>>new threading model in his preclass "4D Server v11 SQL: Understanding
>>>Performance".  So if you attended the Summit this year, I would
>recommend
>>>looking at his session notes, there is a lot of great detail in there.
>>
>**********************************************************************
>Get the speed and power of 4D v11 SQL
>before upgrade prices increase - http://www.4d.com
>  
>
>4D Internet Users Group (4D iNUG)
>FAQ:  http://lists.4d.com/faqnug.html
>Archive:  http://lists.4D.com/archives.html
>Options: https://lists.4d.com/mailman/options/4d_tech
>Unsub:  mailto:4D_Tech-Unsubscribe@...
>**********************************************************************
>


**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: Does v11 support multiple CPUs for converted application?

by MIYAKO :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Alan,

the article mentions that the 500 demo was an upgraded application,
with no change to the code (i.e. no SQL).

http://www.4d.com/jp/support/resources/benchmarks.html

the developer who agreed to have his application used for that demo
identified himself at Josh's session during the Summit pre class,
so obviously its not like we made the whole thing all up.

but more to the point,
the question of SQL vs QUERY is not really an issue over performance,
it has more to do with syntax constraint and the necessity of a  
current selection.

miyako

On 2009/11/11, at 11:35, Alan Chan wrote:

> Hi David,
>
> Thanks for the detailed explanation. According to your  
> understanding, how
> 4D did its demo on 24 cores and make a big deal out of its  
> scalability.
> While some did challange how 4d did its 500 users demo, 4D insists  
> that
> they simulate real world practices like entering new orders and  
> creates
> reporting. Are they all done in SQL and not 4D languages like
> trigger/transaction? How could real world data entry without
> trigger/transaction for any mission critical application. If all new
> entries are done in Trigger, 500 users are doing entries on "one"  
> cpu??? I
> think they could take lunch instead of coffee break after hitting the
> enter key for a single order entry:-) I don't think that 4D assume  
> their
> developers rewritting their mature applications in SQL yet without
> considering other SQL engines.
>
> Any clarification would be greatly appreciated.
>
> Alan Chan
**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: New behavior cause data corruption in v11

by Alan Chan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

One more thing, it must be client/server. No such problem would be
happening in local mode. For a clean test, don't let our clients to login.
In the beginning, we found randome data corruption and difficult to track
down with multiple test engineers accessing the server. We tracked this
down until I assigned only one single engineer to test and he knew exactly
what he did and in what steps.

Alan Chan

4D iNug Technical <4d_tech@...> writes:

>Hi Thomas,
>
>To reproduce the issue and minimize complication, you might want to
>disable automatic relation and use simple query (not even using Relate
>One). Also use simple Transaction and Trigger (no cascade
>trigger/multi-level transaction). It means every step is done in one
>single transaction/trigger and completed.
>
>>1. create some records in Table_1
>>2. create some matching records in Table_2 (1 many record per one record)
>>3. delete one of the early records in Table_2
>Did you delete exactly the record you just created in step 3)? Deleting
>other many records that ralate to other One table would break the test.
>>
>>4. delete the corresponding "one" record in Table_1
>>5. create a new record in Table_1
>>6. create a new record in Table_2
>On step 6, if you debug in trigger, you will see deleted record of Table_1
>on debug window. This deleted record should contain old primarykey and
>same Record Number (you could test its record number in the debug window)
>before you do the query.
>
>I hope this would help.
>
>Alan Chan
>
>**********************************************************************
>Get the speed and power of 4D v11 SQL
>before upgrade prices increase - http://www.4d.com
>  
>
>4D Internet Users Group (4D iNUG)
>FAQ:  http://lists.4d.com/faqnug.html
>Archive:  http://lists.4D.com/archives.html
>Options: https://lists.4d.com/mailman/options/4d_tech
>Unsub:  mailto:4D_Tech-Unsubscribe@...
>**********************************************************************


**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: Does v11 support multiple CPUs for converted application?

by Jeffrey Kain :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 11/10/09 10:21 PM, "Alan Chan" <alan@...> wrote:

> We never used Web server (it's interesting that you think we are using web
> server anyway),

I'm not sure why you would think that. I have no idea what your app does or
doesn't do. I just was stating that 4D code running on the server,
regardless of the context, doesn't get preemptively threaded by 4D.

> This is the statement that confuse me. Since our discussion has already
> covered 4D codes, SQL and Query, what would this other operations from
> client be? I assume SAVE RECORD, SELECTION TO ARRAY is 4D code.

SELECTION TO ARRAY and SAVE RECORD (without a trigger) do not require 4D
code to be executed on the server. I'm not sure I follow your logic.

Jeff

**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: Does v11 support multiple CPUs for converted application?

by Alan Chan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We never used Web server (it's interesting that you think we are using web
server anyway), our application are strict Client/Server mode that users
do data entry and query reports like "what 4D claimed in their 500 users
demo".

You're correct that 4D has been really "clear" that 4D code would not be
preemptively and only SQL and Query would be benefitual to multiple CPUs.
However, like you said, 4D changes a bit that claimed all other operations
(?) would be ultilizing multiple CPUs except 4D codes.

This is the statement that confuse me. Since our discussion has already
covered 4D codes, SQL and Query, what would this other operations from
client be? I assume SAVE RECORD, SELECTION TO ARRAY is 4D code.

I sincerely want to know what codes did this 500 users demo used without
4D code???

Alan Chan

4D iNug Technical <4d_tech@...> writes:

>4D has always been really clear that anything running 4D code would not be
>preemptively threaded. Originally, only queries were going to be
>preemptively threaded, but this changed as we got close to the release of
>4D
>Server to include all database operations that do not involve the direct
>execution of 4D code.
>
>So, triggers, stored procedures, and code running in the web server can't
>run on multiple CPUs. All other database operations that are made from
>clients or other outside connections can all be preemptively threaded. And
>yes, it makes a really big difference in performance in the real world.
>It's
>not imaginary and it's not a trick.
>
>Of course, if your system is 100% trigger/web server/stored procedure
>based,
>you won't get this benefit, but the engine itself is also a lot faster
>than
>v2004.
>
>JEff
>
>On 11/10/09 9:35 PM, "Alan Chan" <alan@...> wrote:
>
>> Thanks for the detailed explanation. According to your understanding,
>how
>> 4D did its demo on 24 cores and make a big deal out of its scalability.
>
>**********************************************************************
>Get the speed and power of 4D v11 SQL
>before upgrade prices increase - http://www.4d.com
>  
>
>4D Internet Users Group (4D iNUG)
>FAQ:  http://lists.4d.com/faqnug.html
>Archive:  http://lists.4D.com/archives.html
>Options: https://lists.4d.com/mailman/options/4d_tech
>Unsub:  mailto:4D_Tech-Unsubscribe@...
>**********************************************************************


**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: Does v11 support multiple CPUs for converted application?

by Alan Chan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Miyako,

>the developer who agreed to have his application used for that demo
>identified himself at Josh's session during the Summit pre class,
>so obviously its not like we made the whole thing all up.

I've never have a single doubt if 4D made this up. It's because we truly
believed what 4D claims - simulating 500 users of doing data entry and
reporting without SQL involved. But now, I was told the same old version
that 4D languages are in single CPU.

Would this 500 user demo be involved SAVE RECORD for order entry and
SELECTION TO ARRAY for reporting? If so, how could this be spread out 24
cores? That's why I was led to believe that all these could be supported
for multiple CPUs. Doesn't it make sense?

I sincerely want to know what codes did this 500 users demo used without
4D code. Then I might be learning from this non-4D codes concept to do
order entries in our application and to take advantage of multiple CPUs.

Alan Chan

**********************************************************************
Get the speed and power of 4D v11 SQL
before upgrade prices increase - http://www.4d.com
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************
< Prev | 1 - 2 - 3 - 4 | Next >