Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-23325

InnoDB silently writes uncompressed data on compression error or if compressed length = 0

    XMLWordPrintable

    Details

      Description

      While working on MDEV-22895, I noticed that if the server is started without a compression library (say, lzma), and innodb_compression_algorithm = lzma, InnoDB can still create, read and write tables with page_compressed=1.

      On further investigation, I found that InnoDB will silently write uncompressed data if the compression fails (returns non-zero status) or if the compressed length is 0.

      storage/innobase/fil/fil0pagecompress.cc#L211-L220

      	ulint write_size = fil_page_compress_low(
      		buf, out_buf, header_len,
      		fil_space_t::get_compression_algo(flags),
      		static_cast<unsigned>(comp_level));
       
      	if (write_size == 0) {
      fail:
      		srv_stats.pages_page_compression_error.inc();
      		return 0;
      	}
      

      To reproduce:

      • On branch feature-compression-service-lzma
      • Start the server with --use-compression=
      • Run:

        SET GLOBAL innodb_compression_algorithm = "lzma";
         
        CREATE TABLE t (a int, b char(20))
        	engine = innodb
        	page_compressed = 1;
         
        INSERT INTO t (a, b) VALUES (0, "abc");
        INSERT INTO t (a, b) VALUES (1, "def");
        INSERT INTO t (a, b) VALUES (2, "ghi");
         
        SELECT * FROM t;
        

      • The is no error.
      • Restart the server with --use-compression=lzma.
      • Run:

        SELECT * FROM t;
        

      • All rows are visible
      • Again, there is no error
      • Run:

        INSERT INTO t (a, b) VALUES (3, "jkl");
        

      • Restart the server with --use-compression=
      • Table is corrupted.

        Attachments

          Activity

            People

            Assignee:
            marko Marko Mäkelä
            Reporter:
            KartikSoneji Kartik Soneji
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:

                Git Integration