Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-2905

dead code: MongoDB Coverity #99881

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Trivial - P5
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: WT2.9.0, 3.2.10, 3.3.14
    • Labels:
      None
    • # Replies:
      6
    • Last comment by Customer:
      true

      Description

      dead code: MongoDB Coverity #99881

        Issue Links

          Activity

          Hide
          keith.bostic Keith Bostic added a comment -

          Michael Cahill, this one is yours.

          Coverity is complaining about dead code in the new eviction code, and I think the complaint is technically correct.

          Here's the code:

            1469  /*
            1470   * __evict_get_ref --
            1471   *      Get a page for eviction.
            1472   */
            1473  static int
            1474  __evict_get_ref(
            1475      WT_SESSION_IMPL *session, bool is_server, WT_BTREE **btreep, WT_REF **refp)
            1476  {
            ...
            1485          is_app = !F_ISSET(session, WT_SESSION_INTERNAL);
            1486          urgent_ok = (!is_app && !is_server) ||
            1487              !WT_EVICT_HAS_WORKERS(session) ||
            1488              __wt_cache_aggressive(session);
            ...
            1587                   * Don't force application threads to evict dirty pages if they
            1588                   * aren't stalled by the amount of dirty data in cache.
            1589                   */
            1590                  if (!urgent_ok && (is_server || (is_app &&
            1591                      !F_ISSET(cache, WT_CACHE_EVICT_DIRTY_HARD))) &&
            1592                      __wt_page_is_modified(evict->ref->page)) {
            1593                          --evict;
            1594                          break;
            1595                  }
          

          Coverity claims that at line 1590, the is_app test is dead code, because is_app must be true.

          At line 1486, urgent_ok is true if neither is_app or is_server is true.

          At line 1590, to test is_app, we first know that urgent_ok is false (so one of is_app and is_server must be true), and we second know that is_server is false, else we wouldn't be testing is_app.

          Is there a restructure that would make Coverity happy?

          Show
          keith.bostic Keith Bostic added a comment - Michael Cahill , this one is yours. Coverity is complaining about dead code in the new eviction code, and I think the complaint is technically correct. Here's the code: 1469 /* 1470 * __evict_get_ref -- 1471 * Get a page for eviction. 1472 */ 1473 static int 1474 __evict_get_ref( 1475 WT_SESSION_IMPL *session, bool is_server, WT_BTREE **btreep, WT_REF **refp) 1476 { ... 1485 is_app = !F_ISSET(session, WT_SESSION_INTERNAL); 1486 urgent_ok = (!is_app && !is_server) || 1487 !WT_EVICT_HAS_WORKERS(session) || 1488 __wt_cache_aggressive(session); ... 1587 * Don't force application threads to evict dirty pages if they 1588 * aren't stalled by the amount of dirty data in cache. 1589 */ 1590 if (!urgent_ok && (is_server || (is_app && 1591 !F_ISSET(cache, WT_CACHE_EVICT_DIRTY_HARD))) && 1592 __wt_page_is_modified(evict->ref->page)) { 1593 --evict; 1594 break; 1595 } Coverity claims that at line 1590, the is_app test is dead code, because is_app must be true. At line 1486, urgent_ok is true if neither is_app or is_server is true. At line 1590, to test is_app , we first know that urgent_ok is false (so one of is_app and is_server must be true), and we second know that is_server is false, else we wouldn't be testing is_app . Is there a restructure that would make Coverity happy?
          Hide
          xgen-internal-githook Githook User added a comment -

          Author:

          {u'username': u'michaelcahill', u'name': u'Michael Cahill', u'email': u'michael.cahill@mongodb.com'}

          Message: WT-2905 dead code: MongoDB Coverity #99881. (#3045)
          Branch: develop
          https://github.com/wiredtiger/wiredtiger/commit/0bf6b4d9ffc468920c3432bf77da1da940576af4

          Show
          xgen-internal-githook Githook User added a comment - Author: {u'username': u'michaelcahill', u'name': u'Michael Cahill', u'email': u'michael.cahill@mongodb.com'} Message: WT-2905 dead code: MongoDB Coverity #99881. (#3045) Branch: develop https://github.com/wiredtiger/wiredtiger/commit/0bf6b4d9ffc468920c3432bf77da1da940576af4
          Hide
          xgen-internal-githook Githook User added a comment -

          Author:

          {u'username': u'michaelcahill', u'name': u'Michael Cahill', u'email': u'michael.cahill@mongodb.com'}

          Message: WT-2905 dead code: MongoDB Coverity #99881. (#3045)
          Branch: mongodb-3.4
          https://github.com/wiredtiger/wiredtiger/commit/0bf6b4d9ffc468920c3432bf77da1da940576af4

          Show
          xgen-internal-githook Githook User added a comment - Author: {u'username': u'michaelcahill', u'name': u'Michael Cahill', u'email': u'michael.cahill@mongodb.com'} Message: WT-2905 dead code: MongoDB Coverity #99881. (#3045) Branch: mongodb-3.4 https://github.com/wiredtiger/wiredtiger/commit/0bf6b4d9ffc468920c3432bf77da1da940576af4
          Hide
          xgen-internal-githook Githook User added a comment -

          Author:

          {u'username': u'agorrod', u'name': u'Alex Gorrod', u'email': u'alexander.gorrod@mongodb.com'}

          Message: Import wiredtiger: 5bc03723a7e77c96b1d5e45a97173654872c727a from branch mongodb-3.4

          ref: deeb0f589a..5bc03723a7
          for: 3.3.13

          WT-2859 Improve statistics macros to not collect stats when statistics=none is set
          WT-2894 Create workload that shows negative scaling when overwhelmed
          WT-2900 Add ARM8 build support to WiredTiger and fix ARM CRC assembler tags
          WT-2902 Enhance eviction to work better with update heavy YCSB load
          WT-2905 dead code: MongoDB Coverity #99881
          WT-2908 Add dry-run support to python unit-test
          WT-2910 test_inmem01 can abort due to stuck cache
          WT-2911 add support for gcc6
          WT-2912 make --enable-strict run on the zseries test box
          WT-2913 stuck cache after latest merge
          WT-2914 Fix link error on OS/X for checksum_init call
          WT-2916 whitespace check not working
          Branch: master
          https://github.com/mongodb/mongo/commit/7693fa59c4470db729d85af99fb9cc3b264fa8c8

          Show
          xgen-internal-githook Githook User added a comment - Author: {u'username': u'agorrod', u'name': u'Alex Gorrod', u'email': u'alexander.gorrod@mongodb.com'} Message: Import wiredtiger: 5bc03723a7e77c96b1d5e45a97173654872c727a from branch mongodb-3.4 ref: deeb0f589a..5bc03723a7 for: 3.3.13 WT-2859 Improve statistics macros to not collect stats when statistics=none is set WT-2894 Create workload that shows negative scaling when overwhelmed WT-2900 Add ARM8 build support to WiredTiger and fix ARM CRC assembler tags WT-2902 Enhance eviction to work better with update heavy YCSB load WT-2905 dead code: MongoDB Coverity #99881 WT-2908 Add dry-run support to python unit-test WT-2910 test_inmem01 can abort due to stuck cache WT-2911 add support for gcc6 WT-2912 make --enable-strict run on the zseries test box WT-2913 stuck cache after latest merge WT-2914 Fix link error on OS/X for checksum_init call WT-2916 whitespace check not working Branch: master https://github.com/mongodb/mongo/commit/7693fa59c4470db729d85af99fb9cc3b264fa8c8
          Hide
          xgen-internal-githook Githook User added a comment -

          Author:

          {u'username': u'michaelcahill', u'name': u'Michael Cahill', u'email': u'michael.cahill@mongodb.com'}

          Message: WT-2905 dead code: MongoDB Coverity #99881. (#3045)
          Branch: mongodb-3.2
          https://github.com/wiredtiger/wiredtiger/commit/0bf6b4d9ffc468920c3432bf77da1da940576af4

          Show
          xgen-internal-githook Githook User added a comment - Author: {u'username': u'michaelcahill', u'name': u'Michael Cahill', u'email': u'michael.cahill@mongodb.com'} Message: WT-2905 dead code: MongoDB Coverity #99881. (#3045) Branch: mongodb-3.2 https://github.com/wiredtiger/wiredtiger/commit/0bf6b4d9ffc468920c3432bf77da1da940576af4
          Hide
          xgen-internal-githook Githook User added a comment -

          Author:

          {u'username': u'michaelcahill', u'name': u'Michael Cahill', u'email': u'michael.cahill@mongodb.com'}

          Message: Import wiredtiger: bb18c439152379fb528af217345be40819b01fc4 from branch mongodb-3.2

          ref: 911c940ada..bb18c43915
          for: 3.2.10

          WT-2859 Improve statistics macros to not collect stats when statistics=none is set
          WT-2894 Create workload that shows negative scaling when overwhelmed
          WT-2900 Add ARM8 build support to WiredTiger and fix ARM CRC assembler tags
          WT-2902 Enhance eviction to work better with update heavy YCSB load
          WT-2905 dead code: MongoDB Coverity #99881
          WT-2908 Add dry-run support to python unit-test
          WT-2910 test_inmem01 can abort due to stuck cache
          WT-2911 add support for gcc6
          WT-2912 make --enable-strict run on the zseries test box
          WT-2913 stuck cache after latest merge
          WT-2914 Fix link error on OS/X for checksum_init call
          WT-2916 whitespace check not working
          Branch: v3.2
          https://github.com/mongodb/mongo/commit/dfca65ea3a32b1e0c832ff7ee2d7b667819ec64d

          Show
          xgen-internal-githook Githook User added a comment - Author: {u'username': u'michaelcahill', u'name': u'Michael Cahill', u'email': u'michael.cahill@mongodb.com'} Message: Import wiredtiger: bb18c439152379fb528af217345be40819b01fc4 from branch mongodb-3.2 ref: 911c940ada..bb18c43915 for: 3.2.10 WT-2859 Improve statistics macros to not collect stats when statistics=none is set WT-2894 Create workload that shows negative scaling when overwhelmed WT-2900 Add ARM8 build support to WiredTiger and fix ARM CRC assembler tags WT-2902 Enhance eviction to work better with update heavy YCSB load WT-2905 dead code: MongoDB Coverity #99881 WT-2908 Add dry-run support to python unit-test WT-2910 test_inmem01 can abort due to stuck cache WT-2911 add support for gcc6 WT-2912 make --enable-strict run on the zseries test box WT-2913 stuck cache after latest merge WT-2914 Fix link error on OS/X for checksum_init call WT-2916 whitespace check not working Branch: v3.2 https://github.com/mongodb/mongo/commit/dfca65ea3a32b1e0c832ff7ee2d7b667819ec64d

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                39 weeks, 5 days ago
                Date of 1st Reply: