caffe icon indicating copy to clipboard operation
caffe copied to clipboard

MDB_CHECK failed

Open BestSonny opened this issue 11 years ago • 10 comments

I try to generate a db file and in a small dataset. It goes well.

While in a bigger dataset, it gives a error message.

Check failed: mdb_status == 0 (-30786 vs. 0) MDB_PAGE_FULL: Internal error - page has no more space.

Anyone?

BestSonny avatar Aug 06 '15 06:08 BestSonny

"Internal error" means this is a bug in the LMDB library. What version of LMDB are you using? The latest release is 0.9.16, you should upgrade to that if you're not on it already, and see if you can still reproduce the problem. If so, please provide details, sample code, checklist of steps to reproduce the problem, etc., at http://www.openldap.org/its/

hyc avatar Aug 23 '15 20:08 hyc

@BestSonny Have u solved the problem? I meet the same problem...

bearpaw avatar Oct 17 '15 10:10 bearpaw

I haven't seen any more details or ITS submitted on this issue. One other, ITS#8221, also involved an MDB_PAGE_FULL error and that has been fixed. http://www.openldap.org/its/index.cgi/Software%20Bugs?id=8221

But that referenced a delete operation. There's nothing in this ticket to tell us what the offending operation was so I have no idea if this is the same issue.

People, if you want your issues to get any resolution, you have to respond.

hyc avatar Oct 17 '15 17:10 hyc

@hyc Thanks for your response!

Actually I found this problem happens if I set -encoded true. If I set -encoded as false, the LMDB will be generated successfully. Still don't know the reason why this issue happened.

bearpaw avatar Oct 18 '15 07:10 bearpaw

I still do not know the reason why it crushed. But when i run the code in another machine, everything goes OK. So I have no idea what's wrong......

BestSonny avatar Oct 18 '15 11:10 BestSonny

Seems it's really a bug for the lmdb. My solution now is trying not to encode the image. and add extra function in the util/io.cpp

cv::Mat DatumToCVMat(const Datum& datum) {
  const string& data = datum.data();
  const int datum_channels = datum.channels();
  const int datum_height = datum.height();
  const int datum_width = datum.width();


  cv::Mat img = cv::Mat(datum_height, datum_width,
      CV_MAKETYPE(CV_8U, datum_channels));

  CHECK(img.depth() == CV_8U) << "unsupported image data type";

  uchar datum_element;
  int index;
  for (int h = 0; h < datum_height; ++h) {
    uchar* ptr = img.ptr<uchar>(h);
    int img_index = 0;
    for (int w = 0; w < datum_width; ++w) {
      for (int c = 0; c < datum_channels; ++c) {

        index = (c * datum_height + h) * datum_width + w;
        datum_element = static_cast<uchar>(static_cast<uint8_t>(data[index]));
        ptr[img_index++] = datum_element;
      }
    }
  }
  return img;
}

cv::Mat DecodeDatumToCVMatNative(const Datum& datum) {
  cv::Mat cv_img;
  if (datum.encoded() == false){
    cv_img = DatumToCVMat(datum);
    return cv_img;  
  }
  const string& data = datum.data();
  std::vector<char> vec_data(data.c_str(), data.c_str() + data.size());
  cv_img = cv::imdecode(vec_data, -1);
  if (!cv_img.data) {
    LOG(ERROR) << "Could not decode datum ";
  }
  return cv_img;
}

BestSonny avatar Nov 24 '15 06:11 BestSonny

This is an old issue but I got the same error on a large dataset. I updated liblmdb-dev package to the version 0.9.16 which resolves my issue. On Ubuntu 14.04, a newer version can be installed from backports:

 sudo apt-get install liblmdb-dev/trusty-backports

basarane avatar Apr 21 '16 16:04 basarane

Thanks. Changing the version of lmdb to 0.9.16 also solved the problem for me

Paethon avatar Jul 27 '16 11:07 Paethon

Thanks. after changing the version of lmdb, it works absolutely fine.

aharishkumar avatar Aug 30 '16 10:08 aharishkumar

I run into this when doing Put to a transaction using liblmdb-dev 0.9.18-5 on ubuntu 17.04. (Building caffe2) This is all writing to a freshly created database, no read/delete. My guess is some particular sequence of write operations/lengths causes this to happen. I'll go file it on another project.

jwatte avatar Oct 01 '17 21:10 jwatte