Commit 7e998e39 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel
Browse files

[t:4541], merge new fix to main

git-svn-id: file:///svn/toku/tokudb@41583 c7de825b-a66e-492c-adef-691d508d4ae1
parent ca9e8dc6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -203,6 +203,7 @@ static void print_defines (void) {
    //printf("#define DB_PRELOCKED_FILE_READ 0x00200000\n"); // private tokudb. No longer supported in #4472
    printf("#define DB_IS_HOT_INDEX 0x00100000\n"); // private tokudb
    printf("#define DBC_DISABLE_PREFETCHING 0x20000000\n"); // private tokudb
    printf("#define DB_UPDATE_CMP_DESCRIPTOR 0x40000000\n"); // private tokudb

    {
        //dbt flags
@@ -424,7 +425,6 @@ static void print_db_struct (void) {
			 "DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */",
			 "DESCRIPTOR cmp_descriptor /* saved row/dictionary descriptor for aiding in comparisons */",
			 "int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, u_int32_t) /* change row/dictionary descriptor for a db.  Available only while db is open */",
			 "int (*update_cmp_descriptor) (DB*) /* Update cmp descriptor.  Available only while db is open */",
			 "int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */",
			 "int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */",
			 "int (*hot_optimize)(DB*, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra)",
+1 −1
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ typedef enum {
#define DB_PRELOCKED_WRITE 0x00400000
#define DB_IS_HOT_INDEX 0x00100000
#define DBC_DISABLE_PREFETCHING 0x20000000
#define DB_UPDATE_CMP_DESCRIPTOR 0x40000000
#define DB_DBT_APPMALLOC 1
#define DB_DBT_DUPOK 2
#define DB_DBT_MALLOC 8
@@ -305,7 +306,6 @@ struct __toku_db {
  DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
  DESCRIPTOR cmp_descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
  int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, u_int32_t) /* change row/dictionary descriptor for a db.  Available only while db is open */;
  int (*update_cmp_descriptor) (DB*) /* Update cmp descriptor.  Available only while db is open */;
  int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */;
  int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */;
  int (*hot_optimize)(DB*, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra);
+22 −15
Original line number Diff line number Diff line
@@ -3504,8 +3504,8 @@ int toku_update_descriptor(struct brt_header * h, DESCRIPTOR d, int fd)
    return r;
}

void 
toku_brt_update_cmp_descriptor(BRT t) {
static void 
brt_update_cmp_descriptor(BRT t) {
    t->h->cmp_descriptor.dbt.size = t->h->descriptor.dbt.size;
    t->h->cmp_descriptor.dbt.data = toku_xmemdup(
        t->h->descriptor.dbt.data, 
@@ -3520,7 +3520,8 @@ toku_brt_change_descriptor(
    const DBT* old_descriptor, 
    const DBT* new_descriptor, 
    BOOL do_log, 
    TOKUTXN txn
    TOKUTXN txn,
    BOOL update_cmp_descriptor
    ) 
{
    int r = 0;
@@ -3550,7 +3551,8 @@ toku_brt_change_descriptor(
            toku_cachefile_filenum(t->cf),
            xid,
            old_desc_bs,
	    new_desc_bs
            new_desc_bs,
            update_cmp_descriptor
            );
        if (r != 0) { goto cleanup; }
    }
@@ -3559,11 +3561,16 @@ toku_brt_change_descriptor(
    new_d.dbt = *new_descriptor;
    fd = toku_cachefile_get_and_pin_fd (t->cf);
    r = toku_update_descriptor(t->h, &new_d, fd);
    if (r == 0)	 // very infrequent operation, worth precise threadsafe count
    // very infrequent operation, worth precise threadsafe count
    if (r == 0) {
        STATUS_VALUE(BRT_DESCRIPTOR_SET)++;
    }
    toku_cachefile_unpin_fd(t->cf);
    if (r!=0) goto cleanup;

    if (update_cmp_descriptor) {
        brt_update_cmp_descriptor(t);
    }
cleanup:
    return r;
}
+1 −2
Original line number Diff line number Diff line
@@ -32,8 +32,7 @@ C_BEGIN
typedef int(*BRT_GET_CALLBACK_FUNCTION)(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra, bool lock_only);

int toku_open_brt (const char *fname, int is_create, BRT *, int nodesize, int basementnodesize, CACHETABLE, TOKUTXN, int(*)(DB *,const DBT*,const DBT*), DB*) __attribute__ ((warn_unused_result));
void toku_brt_update_cmp_descriptor(BRT t);
int toku_brt_change_descriptor(BRT t, const DBT* old_descriptor, const DBT* new_descriptor, BOOL do_log, TOKUTXN txn);
int toku_brt_change_descriptor(BRT t, const DBT* old_descriptor, const DBT* new_descriptor, BOOL do_log, TOKUTXN txn, BOOL update_cmp_descriptor);
int toku_update_descriptor(struct brt_header * h, DESCRIPTOR d, int fd);
// Note: See the locking discussion in brt.c for toku_brt_change_descriptor and toku_update_descriptor.

+1 −0
Original line number Diff line number Diff line
@@ -210,6 +210,7 @@ const struct logtype logtypes[] = {
                            {"TXNID",      "xid", 0},
                            {"BYTESTRING", "old_descriptor", 0},
                            {"BYTESTRING", "new_descriptor", 0},
                            {"BOOL",       "update_cmp_descriptor", 0},
                            NULLFIELD}},
    {0,0,FA{NULLFIELD}}
};
Loading