Uploaded image for project: 'Apache AsterixDB'
  1. Apache AsterixDB
  2. ASTERIXDB-3407

Increment page counter when skipping a valid page's cloud bytes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 0.9.10
    • 0.9.10
    • STO - Storage

    Description

      An issue was observed when testing cloud caching:

      Failure while trying to read a page from disk
      org.apache.hyracks.api.exceptions.HyracksDataException: java.io.IOException: FAILED_TO_UNCOMPRESS(5) 

       

      Given the following code snippet in CloudMegaPageReadContext.java

       @Override
          public void onPin(ICachedPage page) throws HyracksDataException {
              CloudCachedPage cachedPage = (CloudCachedPage) page;
              if (gapStream != null && cachedPage.skipCloudStream()) {
                  /*
                   * This page is requested but the buffer cache has a valid copy in memory. Also, the page itself was
                   * requested to be read from the cloud. Since this page is valid, no buffer cache read() will be performed.
                   * As the buffer cache read() is also responsible for persisting the bytes read from the cloud, we can end
                   * up writing the bytes of this page in the position of another page. Therefore, we should skip the bytes
                   * for this particular page to avoid placing the bytes of this page into another page's position.
                   */
                  try {
                      long remaining = cachedPage.getCompressedPageSize();
                      while (remaining > 0) {
                          remaining -= gapStream.skip(remaining);
                      }
                  } catch (IOException e) {
                      throw HyracksDataException.create(e);
                  }
              }
          } 

       

      The issue appeared when the following sequence is performed to read a range of columnar pages

      1- Reading N valid from the buffer cache (i.e., the buffer cache has those pages cached in memory)

      2- Doing a read of a page that requires to be retrieved from the cloud. A stream will be created. However, pageCounter was never incremented when the N valid pages where pinned.

      3- The created stream will start from the page that requires to be read from the cloud in addition to numberOfContiguousPages - pageCounter. The issue is pageCounter was never incremented (i.e., it is 0). Thus, we will request more pages than we suppose to read. This will be OK if the component has those pages. However, if the requested range of pages exceeds the component's pages, then an undefined behavior will occur. In the case with compressed pages, we got an incompressible page. 

      Attachments

        Activity

          People

            wyk Wail Y. Alkowaileet
            wyk Wail Y. Alkowaileet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: