Issue Details (XML | Word | Printable)

Key: CORE-5596
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Oleg Matveyev
Votes: 0
Watchers: 5
Operations

If you were logged in you would be able to see more operations.
Firebird Core

internal Firebird consistency check ((CMP) copy: cannot remap (221), file: cmp.cpp line: 3085).

Created: 22/Aug/17 06:04 PM   Updated: 22/Nov/17 05:50 AM
Component/s: Engine
Affects Version/s: 2.5.6
Fix Version/s: 3.0.2, 4.0 Alpha 1

File Attachments: 1. File CORE-5596.7z (47 kB)
2. File core-5596.sql (3 kB)
3. File firebird.conf (27 kB)

Environment:
2.5.6.26967 Firebird Cliassic Server x64, Windows 8.1
Dialect 1. Database file in attachment. page size 16Kb

firebird.conf:
ExternalFileAccess = Restrict D:\Temp
TempDirectories = d:\temp;c:\temp
DefaultDbCachePages = 3584
FileSystemCacheThreshold = 165536
TempCacheLimit = 640000000
LockMemSize = 28672000
LockHashSlots = 10007

Issue Links:
Relate
 

QA Status: Covered by another test(s)
Test Details: See test for CORE-1095 (added there simplified code based on this ticket).


 Description  « Hide
Prepare query with error:
internal Firebird consistency check ((CMP) copy: cannot remap (221), file: cmp.cpp line: 3085).

___________________________________
SELECT mg.dbBrutto_Full
, COALESCE(
             Round((
      IIF( exists(select g.id from c_goodSpec gs, c_good g where gs.id = mg.idGoodspec and g.id = gs.idGood and g.idMera0 = 2)
        , mg.dbBrutto_Count0 * (mg.dbCount0 - (select count(mgi.id) from c_move_good_item mgi where mgi.idMoveGood = mg.id /*and mgi.iNumber <> 0*/ and mgi.dbBrutto > 0.001))
        , mg.dbBrutto_Count0 * (mg.dbCount0 - COALESCE((select sum(mgi.dbCountList) from c_move_good_item mgi where mgi.idMoveGood = mg.id /*and mgi.iNumber <> 0*/ and mgi.dbBrutto > 0.001), 0e0))
          )
       + (select (CASE(3)
           WHEN g.idMera0 THEN mg.dbCount0
           WHEN g.idMera1 THEN mg.dbCount1
           WHEN g.idMera2 THEN mg.dbCount2
           WHEN g.idMera3 THEN mg.dbCount3
           ELSE 0.0
           END) from c_goodSpec gs, c_good g
            where gs.id = mg.idGoodspec
              and g.id = gs.idGood
            ) * 28.58
       + COALESCE((select sum(mgi.dbBrutto) from C_Move_Good_Item mgi where mgi.idMoveGood = mg.id /*and mgi.iNumber <> 0*/ and mgi.dbBrutto > 0.001), 0e0)
      ),0)
      , 0)

FROM C_Move_Good mg
JOIN C_move m ON m.id=mg.idMove
    WHERE m.dtDay >= '01.01.2017' AND m.iRouteType=2
  AND mg.ibRekv=0
      AND (mg.dbBrutto_Full - COALESCE(
                               Round((IIF( exists(select g.id from c_goodSpec gs, c_good g where gs.id = mg.idGoodspec and g.id = gs.idGood and g.idMera0 = :idMera_Pack)
                                  , mg.dbBrutto_Count0 * (mg.dbCount0 - (select count(mgi.id) from c_move_good_item mgi where mgi.idMoveGood = mg.id and mgi.dbBrutto > 0.001))
                                  , mg.dbBrutto_Count0 * (mg.dbCount0 - COALESCE((select sum(mgi.dbCountList) from c_move_good_item mgi where mgi.idMoveGood = mg.id and mgi.dbBrutto > 0.001), 0e0))
                                    )
                                 + (select (CASE(3)
                                   WHEN g.idMera0 THEN mg.dbCount0
                                   WHEN g.idMera1 THEN mg.dbCount1
                                   WHEN g.idMera2 THEN mg.dbCount2
                                   WHEN g.idMera3 THEN mg.dbCount3
                                   ELSE 0.0
                                   END) from c_goodSpec gs, c_good g
                                    where gs.id = mg.idGoodspec
                                      and g.id = gs.idGood
                                   ) * 28.58
                                 + COALESCE((select sum(mgi.dbBrutto) from C_Move_Good_Item mgi where mgi.idMoveGood = mg.id and mgi.dbBrutto > 0.001), 0e0)
                                ),0)
                                , 0)
          )
          BETWEEN -0.001 AND 0.001
      AND EXISTS( select * from c_goodSpec gs, c_good g
                  where gs.id = mg.idGoodspec
                    and g.id = gs.idGood
                    and (g.idMera0 = 3 OR g.idMera1 = 3
                          OR g.idMera2 = 3 OR g.idMera3 = 3));


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Sean Leyne added a comment - 22/Aug/17 06:24 PM
Running which engine version? (Classic, SuperServer)?

What firebird.conf settings? Db page size? Page cache size?

Oleg Matveyev added a comment - 22/Aug/17 06:40 PM
2.5.6.26967 Firebird Cliassic Server x64, Windows 8.1
Dialect 1. Database file in attachment. page size 16Kb

firebird.conf:
ExternalFileAccess = Restrict D:\Temp
TempDirectories = d:\temp;c:\temp
DefaultDbCachePages = 3584
FileSystemCacheThreshold = 165536
TempCacheLimit = 640000000
LockMemSize = 28672000
LockHashSlots = 10007

Sean Leyne added a comment - 22/Aug/17 06:48 PM
Your config settings look odd (too big) for a Classic server config.

How many db connections are active simultaneously?

Oleg Matveyev added a comment - 22/Aug/17 06:55 PM
This a test server, 3-10 connections

Sean Leyne added a comment - 22/Aug/17 07:01 PM
What OS is server, how much RAM does it have?

Oleg Matveyev added a comment - 22/Aug/17 07:33 PM
Again: Windows 8.1, x64 of course
32Gb RAM

Really, all this is important?

Dmitry Yemanov added a comment - 27/Aug/17 03:29 PM
This is a BLR compiler problem, it has nothing to do with the environment.

Oleg Matveyev added a comment - 27/Aug/17 07:44 PM
Change explicit join to implicit join no any change:

FROM C_Move_Good mg
JOIN C_move m ON m.id=mg.idMove
    WHERE m.dtDay >= '01.01.2017' AND m.iRouteType=2
  AND mg.ibRekv=0

FROM C_Move_Good mg, C_move m
    WHERE m.id=mg.idMove AND m.dtDay >= '01.01.2017' AND m.iRouteType=2
  AND mg.ibRekv=0
 
Bug is reproduced in any case

Dmitry Yemanov added a comment - 21/Nov/17 12:22 PM
The problem is inside this construct:
(EXPRESSION WITH NESTED SUBQUERY) BETWEEN -0.001 AND 0.001

Fixed in v3.0.2, see also CORE-1095. Unlikely to be backported into v2.5.x.