Skip to content

Tests are flaky again #14161

Open
Open

Description

@ephys

This issue aims to document the various tests that fail randomly on the CI.

https://github.com/sequelize/sequelize/runs/5320675964?check_suite_focus=true

# mariadb 10.5 (node 16)
  1) [MARIADB] Pooling
       idle
         [MSSQL Flaky] should get new connection beyond idle range:

      AssertionError: expected 46 to not equal 46
      + expected - actual


      at Proxy.assertEqual (node_modules/chai/lib/chai/core/assertions.js:1038:12)
      at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25)
      at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22)
      at Proxy.<anonymous> (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20)
      at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33)
      at assertNewConnection (test/integration/pool.test.js:47:48)
      at Context.<anonymous> (test/integration/pool.test.js:213:7)
      at runMicrotasks (<anonymous>)
      at runNextTicks (node:internal/process/task_queues:61:5)
      at processTimers (node:internal/timers:499:9)

https://github.com/sequelize/sequelize/runs/5152023145?check_suite_focus=true

# sqlite (node 12)
 1) [SQLITE] Transaction
       fails with SQLITE_BUSY when retry.match is changed:
     AssertionError: expected promise to be rejected with an error including 'SQLITE_BUSY: database is locked' but it was fulfilled with [ undefined, undefined ]
      at assertIfNotNegated (node_modules/chai-as-promised/lib/chai-as-promised.js:68:19)
      at /home/runner/work/sequelize/sequelize/node_modules/chai-as-promised/lib/chai-as-promised.js:183:17
      at async Context.<anonymous> (test/integration/transaction.test.js:739:9)

https://github.com/sequelize/sequelize/runs/5156282992?check_suite_focus=true

# mariadb 10.5 (node 12)

 1) [MARIADB] Model
       scope
         complex merge
           should merge complex scopes with findAll options correctly regardless of their order:

      AssertionError: expected { id: 1, name: 'foo1', bars: [ …(2) ] } to deeply equal { id: 1, name: 'foo1', bars: [ …(2) ] }
      + expected - actual

           {
             "bazs": [
               {
                 "barId": 1
      -          "id": 2
      +          "id": 1
                 "quxes": [
                   {
      -              "bazId": 2
      -              "id": 1
      -              "name": "qux3"
      +              "bazId": 1
      +              "id": 3
      +              "name": "qux1"
                   }
                   {
      -              "bazId": 2
      -              "id": 2
      -              "name": "qux4"
      +              "bazId": 1
      +              "id": 4
      +              "name": "qux2"
                   }
                 ]
               }
               {
                 "barId": 1
      -          "id": 1
      +          "id": 2
                 "quxes": [
                   {
      -              "bazId": 1
      -              "id": 3
      -              "name": "qux1"
      +              "bazId": 2
      +              "id": 1
      +              "name": "qux3"
                   }
                   {
      -              "bazId": 1
      -              "id": 4
      -              "name": "qux2"
      +              "bazId": 2
      +              "id": 2
      +              "name": "qux4"
                   }
                 ]
               }
             ]
      
      at Proxy.assertEql (node_modules/chai/lib/chai/core/assertions.js:1096:10)
      at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25)
      at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22)
      at Proxy.<anonymous> (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20)
      at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33)
      at Proxy.assertEqual (node_modules/chai/lib/chai/core/assertions.js:1035:12)
      at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25)
      at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22)
      at Proxy.<anonymous> (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20)
      at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33)
      at Context.<anonymous> (test/integration/model/scope/merge.test.js:185:43)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

Activity

  1. added
    hard to reproduce
    on Feb 24, 2022
  2. ephys commented on Feb 24, 2022

    @ephys
    MemberAuthor

    Looks like we sometimes have an issue when installing obdc: https://github.com/sequelize/sequelize/runs/5321167027?check_suite_focus=true

    yarn install v1.22.17
    [1/4] Resolving packages...
    [2/4] Fetching packages...
    [3/4] Linking dependencies...
    warning "@ephys/eslint-config-typescript > [email protected]" has unmet peer dependency "eslint-plugin-import@*".
    warning "@ephys/eslint-config-typescript > @ephys/eslint-config > [email protected]" has incorrect peer dependency "eslint@^6.1.0".
    warning "snowflake-sdk > [email protected]" has unmet peer dependency "asn1.js@^5.0.0".
    warning Workspaces can only be enabled in private projects.
    [4/4] Building fresh packages...
    info Visit [yarnpkg.com/en/docs/cli/install](https://yarnpkg.com/en/docs/cli/install) for documentation about this command.
    error /home/runner/work/sequelize/sequelize/node_modules/odbc: Command failed.
    Exit code: 126
    Command: node-pre-gyp install --fallback-to-build
    Arguments: 
    Directory: /home/runner/work/sequelize/sequelize/node_modules/odbc
    Output:
    /usr/bin/env: ‘node’: Text file busy
    Error: Process completed with exit code 126.
    

    @markdirish I think you're the most qualified to take a look at it if you can :)

    We could work around this issue by only installing dialects that are relevant for the test being run. Might speed up install times toi

  3. WikiRik commented on Feb 24, 2022

    @WikiRik
    Member

    I also have these DB2 tests written down that are flaky;

    [DB2] Model
         sync
            should not alter table if data type does not change:
         TypeError: Cannot read property 'dataValues' of null
          at Context.<anonymous> (test/integration/model/sync.test.js:135:19)
    
    [DB2] Model
           sync
             indexes
               with alter:true
                 should not duplicate named indexes after multiple sync calls:
          AssertionError: expected [] to have a length of 1 but got +0
          + expected - actual
          -0
          +1
    
    [DB2] QueryInterface
           removeColumn
             (with a schema)
               should be able to remove a column with unique contraint:
        [IBM][CLI Driver][DB2/LINUXX8664] SQL0195N  Last column of "users" cannot be dropped.
     Error
          at Query._run (lib/dialects/db2/query.js:30:22)
          at Query.run (lib/dialects/db2/query.js:157:23)
          at /home/runner/work/sequelize/sequelize/lib/sequelize.js:315:28
          at runMicrotasks (<anonymous>)
          at processTicksAndRejections (internal/process/task_queues.js:97:5)
          at async Context.<anonymous> (test/integration/query-interface/removeColumn.test.js:166:11)
    
    [DB2] QueryInterface
           changeColumn
             should support schemas:
        [IBM][CLI Driver][DB2/LINUXX8664] SQL0205N  Column, attribute, or period "currency" is not defined in "archive.users".  SQLSTATE=42703
      Error
          at Query._run (lib/dialects/db2/query.js:30:22)
          at Query.run (lib/dialects/db2/query.js:157:23)
          at /home/runner/work/sequelize/sequelize/lib/sequelize.js:315:28
          at runMicrotasks (<anonymous>)
          at processTicksAndRejections (node:internal/process/task_queues:96:5)
          at async Context.<anonymous> (test/integration/query-interface/changeColumn.test.js:37:7)
    
    [DB2] Pooling
           network / connection errors
             should obtain new connection when old connection is abruptly closed:
         AssertionError: expected true to be falsy
          at Assertion.<anonymous> (node_modules/chai/lib/chai/core/assertions.js:633:10)
          at Assertion.propertyGetter (node_modules/chai/lib/chai/utils/addProperty.js:62:29)
          at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22)
          at Assertion.<anonymous> (node_modules/chai-as-promised/lib/chai-as-promised.js:280:43)
          at Assertion.overwritingPropertyGetter (node_modules/chai/lib/chai/utils/overwriteProperty.js:79:37)
          at Object.proxyGetter [as get] (node_modules/chai/lib/chai/utils/proxify.js:98:22)
          at assertNewConnection (test/integration/pool.test.js:51:48)
          at Context.<anonymous> (test/integration/pool.test.js:111:7)
    
    [DB2] QueryInterface
           removeColumn
             (with a schema)
               [Flaky] should be able to remove a column with a default value:
         [IBM][CLI Driver][DB2/LINUXX8664] SQL0205N  Column, attribute, or period "firstName" is not defined in "archive.users".  SQLSTATE=42703
     Error
          at Query._run (lib/dialects/db2/query.js:30:22)
          at Query.run (lib/dialects/db2/query.js:157:23)
          at /home/runner/work/sequelize/sequelize/lib/sequelize.js:315:28
          at runMicrotasks (<anonymous>)
          at processTicksAndRejections (node:internal/process/task_queues:96:5)
          at async Context.<anonymous> (test/integration/query-interface/removeColumn.test.js:119:9)
    
    [DB2] QueryInterface
           removeColumn
             (with a schema)
               should be able to remove a column without default value:
         [IBM][CLI Driver][DB2/LINUXX8664] SQL0205N  Column, attribute, or period "lastName" is not defined in "archive.users".  SQLSTATE=42703
      Error
          at Query._run (lib/dialects/db2/query.js:30:22)
          at Query.run (lib/dialects/db2/query.js:157:23)
          at /home/runner/work/sequelize/sequelize/lib/sequelize.js:315:28
          at runMicrotasks (<anonymous>)
          at processTicksAndRejections (internal/process/task_queues.js:97:5)
          at async Context.<anonymous> (test/integration/query-interface/removeColumn.test.js:133:9)
    
  4. github-actions commented on Mar 11, 2022

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

  5. added
    type: bug
    and removed on Mar 11, 2022
  6. added
    type: other
    and removed
    type: bug
    on Mar 11, 2022
  7. WikiRik commented on Jun 16, 2022

    @WikiRik
    Member

    New one with postgres;

      1) [POSTGRES-NATIVE] associations
           scope
             N:M
               on the target
                 should create, find and include associations with scope values:
          AssertionError: expected [ 1, 1, 1, +0, 1, 1 ] to deeply equal [ 1, 1, 1, 1, 1, 1 ]
          + expected - actual
           [
             1
             1
             1
          -  0
             1
             1
          +  1
           ]
          at Proxy.assertEql (node_modules/chai/lib/chai/core/assertions.js:1096:10)
          at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25)
          at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22)
          at Proxy.<anonymous> (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20)
          at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33)
          at Context.<anonymous> (test/integration/associations/scope.test.js:392:19)
    
  8. ephys commented on Jul 10, 2022

    @ephys
    MemberAuthor

    Fix for the recent postgres one: #14738

  9. WikiRik commented on Jun 24, 2023

    @WikiRik
    Member

    Updated list of flaky tests I could find from the past weeks;

    it('[Flaky] should get new connection beyond idle range', async () => {
    const sequelize = createSingleTestSequelizeInstance({
    pool: { max: 1, idle: 100, evict: 10 },
    });
    const cm = sequelize.connectionManager;
    await sequelize.sync();
    const firstConnection = await cm.getConnection();
    // TODO - Do we really need this call?
    attachMSSQLUniqueId(firstConnection);
    // returning connection back to pool
    await cm.releaseConnection(firstConnection);
    // Wait a little and then get next available connection
    await delay(110);
    const secondConnection = await cm.getConnection();
    assertNewConnection(secondConnection, firstConnection);
    expect(cm.validate(firstConnection)).not.to.be.ok;
    await cm.releaseConnection(secondConnection);
    });

    Seen failing on; postgres (11-2.5, 15-3.3), mssql (2022-latest), mysql (5.7.8, 8.0.33)


    it('does not duplicate columns in ORDER BY statement, #9008', async function () {
    const LoginLog = this.sequelize.define('LoginLog', {
    ID: {
    field: 'id',
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
    },
    UserID: {
    field: 'userid',
    type: DataTypes.UUID,
    allowNull: false,
    },
    });
    const User = this.sequelize.define('User', {
    UserID: {
    field: 'userid',
    type: DataTypes.UUID,
    defaultValue: DataTypes.UUIDV4,
    primaryKey: true,
    },
    UserName: {
    field: 'username',
    type: DataTypes.STRING(50),
    allowNull: false,
    },
    });
    LoginLog.belongsTo(User, {
    foreignKey: 'UserID',
    });
    User.hasMany(LoginLog, {
    foreignKey: 'UserID',
    });
    await this.sequelize.sync({ force: true });
    const [vyom, shakti, nikita, arya] = await User.bulkCreate([
    { UserName: 'Vayom' },
    { UserName: 'Shaktimaan' },
    { UserName: 'Nikita' },
    { UserName: 'Aryamaan' },
    ], { returning: true });
    await Promise.all([
    vyom.createLoginLog(),
    shakti.createLoginLog(),
    nikita.createLoginLog(),
    arya.createLoginLog(),
    ]);
    const logs = await LoginLog.findAll({
    include: [
    {
    model: User,
    where: {
    UserName: {
    [Op.like]: '%maan%',
    },
    },
    },
    ],
    order: [[User, 'UserName', 'DESC']],
    offset: 0,
    limit: 10,
    });
    expect(logs).to.have.length(2);
    expect(logs[0].User.get('UserName')).to.equal('Shaktimaan');
    expect(logs[1].User.get('UserName')).to.equal('Aryamaan');
    // #11258 and similar
    const otherLogs = await LoginLog.findAll({
    include: [
    {
    model: User,
    where: {
    UserName: {
    [Op.like]: '%maan%',
    },
    },
    },
    ],
    order: [['id', 'DESC']],
    offset: 0,
    limit: 10,
    });
    expect(otherLogs).to.have.length(2);
    expect(otherLogs[0].User.get('UserName')).to.equal('Aryamaan');
    expect(otherLogs[1].User.get('UserName')).to.equal('Shaktimaan');
    // Separate queries can apply order freely
    const separateUsers = await User.findAll({
    include: [
    {
    model: LoginLog,
    separate: true,
    order: [
    'id',
    ],
    },
    ],
    where: {
    UserName: {
    [Op.like]: '%maan%',
    },
    },
    order: ['UserName', ['UserID', 'DESC']],
    offset: 0,
    limit: 10,
    });
    expect(separateUsers).to.have.length(2);
    expect(separateUsers[0].get('UserName')).to.equal('Aryamaan');
    expect(separateUsers[0].get('LoginLogs')).to.have.length(1);
    expect(separateUsers[1].get('UserName')).to.equal('Shaktimaan');
    expect(separateUsers[1].get('LoginLogs')).to.have.length(1);
    });

    Seen failing on; mssql (2017-latest, 2022-latest)


    it('fails with SQLITE_BUSY when retry.match is changed', async function () {
    const sequelize = await Support.createSingleTransactionalTestSequelizeInstance(this.sequelize);
    const User = sequelize.define('User', { id: { type: DataTypes.INTEGER, primaryKey: true }, username: DataTypes.STRING });
    await User.sync({ force: true });
    const newTransactionFunc = async function () {
    const t = await sequelize.startUnmanagedTransaction({ type: Transaction.TYPES.EXCLUSIVE, retry: { match: ['NO_MATCH'] } });
    // introduce delay to force the busy state race condition to fail
    await delay(1000);
    await User.create({ id: null, username: `test ${t.id}` }, { transaction: t });
    return t.commit();
    };
    await expect(Promise.all([newTransactionFunc(), newTransactionFunc()])).to.be.rejectedWith('SQLITE_BUSY: database is locked');
    });

    Seen failing on; sqlite


    More checks have failed in CI steps before the integration testing, but we can look at them seperately.

  10. WikiRik commented on Jun 26, 2023

    @WikiRik
    Member

    One thing that is very flaky right now is mysql latest;

    + ./../../wait-until-healthy.sh sequelize-mysql-latest
    sequelize-mysql-latest is healthy!
    + docker exec sequelize-mysql-latest mysql --host 127.0.0.1 --port 3306 -uroot -psequelize_test -e 'GRANT ALL ON *.* TO '\''sequelize_test'\''@'\''%'\'' with grant option; FLUSH PRIVILEGES;'
    Warning: arning] Using a password on the command line interface can be insecure.
    ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:3306' (111)
    Error: Process completed with exit code 1.
    
  11. WikiRik commented on Jul 8, 2023

    @WikiRik
    Member

    The transaction and pool tests haven't failed since the delay was increased. So it's just the mssql test and the startup of mysql latest left

  12. WikiRik commented on Jul 13, 2023

    @WikiRik
    Member

    #16263 and #16264 also both add additional waiting times in the hopes that it's not flaky anymore. If these are successful we can close this issue for now

  13. added theissue type on Mar 9, 2025
  14. removed
    type: other
    on Mar 9, 2025
  15. wikirik-agent commented on Sep 17, 2026

    @wikirik-agent
    Contributor

    Two intermittent failures seen while running the integration tests locally (2026-09-17):

    oracle (gvenzl/oracle-free 23.26.3): QueryInterface#listTables › should show all tables

    AssertionError: expected [ 'my_test_table2', 'my_test_table1' ] to deeply equal [ 'my_test_table1', 'my_test_table2' ]
    

    The test expects the tables in creation order, but the oracle listTablesQuery has no ORDER BY, so Oracle can return them in any order. Adding an ORDER BY to the query, or sorting in the test, should fix it.

    db2 (icr.io/db2_community/db2 12.1.5.0): Model.sync & Sequelize#sync, in a before hook

    SequelizeDatabaseError: [IBM][CLI Driver][DB2/LINUXX8664] SQL0911N The current transaction has been rolled back because of a deadlock or timeout. Reason code "2". SQLSTATE=40001
    

    This happened once at the start of model/sync.test.js (on the #18406 branch), after several other suites had run against the same instance. Rerunning the file passed. Reason code 2 means a deadlock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hard to reproduce

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions