public synchronized boolean ensureEraseLater(long id, long currentTimeMs) {
        // 1. not in idToRecycleTime, maybe already erased, sorry it's too late!
        if (!idToRecycleTime.containsKey(id)) {
            return false;
        }
        // 2. will expire after quite a long time, don't worry
        long latency = currentTimeMs - idToRecycleTime.get(id);
        if (latency < (Config.catalog_trash_expire_second - LATE_RECYCLE_INTERVAL_SECONDS) * 1000L) {
            return true;
        }
        // 3. already expired, sorry.
        if (latency > Config.catalog_trash_expire_second * 1000L) {
            return false;
        }
        enableEraseLater.add(id);
        return true;
    }
@Test
    public void testEnsureEraseLater() {
        Config.catalog_trash_expire_second = 600; // set expire in 10 minutes
        CatalogRecycleBin recycleBin = new CatalogRecycleBin();
        Database db = new Database(111, "uno");
        recycleBin.recycleDatabase(db, new HashSet<>());

        // no need to set enable erase later if there are a lot of time left
        long now = System.currentTimeMillis();
        Assert.assertTrue(recycleBin.ensureEraseLater(db.getId(), now));
        Assert.assertFalse(recycleBin.enableEraseLater.contains(db.getId()));

        // no need to set enable erase later if already exipre
        long moreThanTenMinutesLater = now + 620 * 1000L;
        Assert.assertFalse(recycleBin.ensureEraseLater(db.getId(), moreThanTenMinutesLater));
        Assert.assertFalse(recycleBin.enableEraseLater.contains(db.getId()));

        // now we should set enable erase later because we are about to expire
        long moreThanNineMinutesLater = now + 550 * 1000L;
        Assert.assertTrue(recycleBin.ensureEraseLater(db.getId(), moreThanNineMinutesLater));
        Assert.assertTrue(recycleBin.enableEraseLater.contains(db.getId()));

        // if already expired, we should return false but won't erase the flag
        Assert.assertFalse(recycleBin.ensureEraseLater(db.getId(), moreThanTenMinutesLater));
        Assert.assertTrue(recycleBin.enableEraseLater.contains(db.getId()));
    }