diff --git a/buildheader/db.h_4_1 b/buildheader/db.h_4_1 index 2ed4608db8e5821cd28ee32752d76543ba9d0430..bd9f95f01b51e98328bd8e113b65acc6b0c74eb4 100644 --- a/buildheader/db.h_4_1 +++ b/buildheader/db.h_4_1 @@ -55,6 +55,7 @@ struct __toku_loader { int (*abort)(DB_LOADER *loader); /* abort loading, free memory */ }; typedef struct __toku_engine_status { + char creationtime[26]; /* time of environment creation */ char startuptime[26]; /* time of engine startup */ char now[26]; /* time of engine status query (i.e. now) */ u_int64_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ @@ -146,6 +147,10 @@ typedef struct __toku_engine_status { u_int64_t upgrade_header; /* how many brt headers were upgraded? */ u_int64_t upgrade_nonleaf; /* how many brt nonleaf nodes were upgraded? */ u_int64_t upgrade_leaf; /* how many brt leaf nodes were upgraded? */ + u_int64_t original_ver; /* original environment version */ + u_int64_t ver_at_startup; /* environment version at startup */ + u_int64_t last_lsn_v12; /* last lsn of version 12 environment */ + char upgrade_v13_time[26]; /* timestamp of when upgrade to version 13 environment was done */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/buildheader/db.h_4_3 b/buildheader/db.h_4_3 index 9fba7f9d4db2c18f214f307430a24f479b0fe7ec..7d64a7b8ed922ab79408711a3080febb00a05651 100644 --- a/buildheader/db.h_4_3 +++ b/buildheader/db.h_4_3 @@ -55,6 +55,7 @@ struct __toku_loader { int (*abort)(DB_LOADER *loader); /* abort loading, free memory */ }; typedef struct __toku_engine_status { + char creationtime[26]; /* time of environment creation */ char startuptime[26]; /* time of engine startup */ char now[26]; /* time of engine status query (i.e. now) */ u_int64_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ @@ -146,6 +147,10 @@ typedef struct __toku_engine_status { u_int64_t upgrade_header; /* how many brt headers were upgraded? */ u_int64_t upgrade_nonleaf; /* how many brt nonleaf nodes were upgraded? */ u_int64_t upgrade_leaf; /* how many brt leaf nodes were upgraded? */ + u_int64_t original_ver; /* original environment version */ + u_int64_t ver_at_startup; /* environment version at startup */ + u_int64_t last_lsn_v12; /* last lsn of version 12 environment */ + char upgrade_v13_time[26]; /* timestamp of when upgrade to version 13 environment was done */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/buildheader/db.h_4_4 b/buildheader/db.h_4_4 index baae6cea3d393695108c9dc91bf94420cb7865fb..25466690f8fb131a8b4f00ed481f69738c54dc04 100644 --- a/buildheader/db.h_4_4 +++ b/buildheader/db.h_4_4 @@ -55,6 +55,7 @@ struct __toku_loader { int (*abort)(DB_LOADER *loader); /* abort loading, free memory */ }; typedef struct __toku_engine_status { + char creationtime[26]; /* time of environment creation */ char startuptime[26]; /* time of engine startup */ char now[26]; /* time of engine status query (i.e. now) */ u_int64_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ @@ -146,6 +147,10 @@ typedef struct __toku_engine_status { u_int64_t upgrade_header; /* how many brt headers were upgraded? */ u_int64_t upgrade_nonleaf; /* how many brt nonleaf nodes were upgraded? */ u_int64_t upgrade_leaf; /* how many brt leaf nodes were upgraded? */ + u_int64_t original_ver; /* original environment version */ + u_int64_t ver_at_startup; /* environment version at startup */ + u_int64_t last_lsn_v12; /* last lsn of version 12 environment */ + char upgrade_v13_time[26]; /* timestamp of when upgrade to version 13 environment was done */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/buildheader/db.h_4_5 b/buildheader/db.h_4_5 index a183479aeeb0ac1ab8f799fd8690aa1b699ca44d..b81b83a3055b705900ca90fae3414b3e535b6788 100644 --- a/buildheader/db.h_4_5 +++ b/buildheader/db.h_4_5 @@ -55,6 +55,7 @@ struct __toku_loader { int (*abort)(DB_LOADER *loader); /* abort loading, free memory */ }; typedef struct __toku_engine_status { + char creationtime[26]; /* time of environment creation */ char startuptime[26]; /* time of engine startup */ char now[26]; /* time of engine status query (i.e. now) */ u_int64_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ @@ -146,6 +147,10 @@ typedef struct __toku_engine_status { u_int64_t upgrade_header; /* how many brt headers were upgraded? */ u_int64_t upgrade_nonleaf; /* how many brt nonleaf nodes were upgraded? */ u_int64_t upgrade_leaf; /* how many brt leaf nodes were upgraded? */ + u_int64_t original_ver; /* original environment version */ + u_int64_t ver_at_startup; /* environment version at startup */ + u_int64_t last_lsn_v12; /* last lsn of version 12 environment */ + char upgrade_v13_time[26]; /* timestamp of when upgrade to version 13 environment was done */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/buildheader/db.h_4_6 b/buildheader/db.h_4_6 index 43a5a976789b8c77be4761129144ae5571e73db7..ccfd0f975875ebb7876ad2db46aa621a7c821d09 100644 --- a/buildheader/db.h_4_6 +++ b/buildheader/db.h_4_6 @@ -55,6 +55,7 @@ struct __toku_loader { int (*abort)(DB_LOADER *loader); /* abort loading, free memory */ }; typedef struct __toku_engine_status { + char creationtime[26]; /* time of environment creation */ char startuptime[26]; /* time of engine startup */ char now[26]; /* time of engine status query (i.e. now) */ u_int64_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ @@ -146,6 +147,10 @@ typedef struct __toku_engine_status { u_int64_t upgrade_header; /* how many brt headers were upgraded? */ u_int64_t upgrade_nonleaf; /* how many brt nonleaf nodes were upgraded? */ u_int64_t upgrade_leaf; /* how many brt leaf nodes were upgraded? */ + u_int64_t original_ver; /* original environment version */ + u_int64_t ver_at_startup; /* environment version at startup */ + u_int64_t last_lsn_v12; /* last lsn of version 12 environment */ + char upgrade_v13_time[26]; /* timestamp of when upgrade to version 13 environment was done */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/buildheader/make_db_h.c b/buildheader/make_db_h.c index 39893555139df5bf3eb019ed8efd04ba741f51ba..9f277581a87eb033cc0dc597c6e3e814d9ff8c18 100644 --- a/buildheader/make_db_h.c +++ b/buildheader/make_db_h.c @@ -439,6 +439,7 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__ //engine status info printf("typedef struct __toku_engine_status {\n"); + printf(" char creationtime[26]; /* time of environment creation */ \n"); printf(" char startuptime[26]; /* time of engine startup */ \n"); printf(" char now[26]; /* time of engine status query (i.e. now) */ \n"); printf(" u_int64_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ \n"); @@ -530,6 +531,10 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__ printf(" u_int64_t upgrade_header; /* how many brt headers were upgraded? */ \n"); printf(" u_int64_t upgrade_nonleaf; /* how many brt nonleaf nodes were upgraded? */ \n"); printf(" u_int64_t upgrade_leaf; /* how many brt leaf nodes were upgraded? */ \n"); + printf(" u_int64_t original_ver; /* original environment version */ \n"); + printf(" u_int64_t ver_at_startup; /* environment version at startup */ \n"); + printf(" u_int64_t last_lsn_v12; /* last lsn of version 12 environment */ \n"); + printf(" char upgrade_v13_time[26]; /* timestamp of when upgrade to version 13 environment was done */ \n"); printf("} ENGINE_STATUS;\n"); print_dbtype(); diff --git a/buildheader/tdb.h b/buildheader/tdb.h index b75bb56d6d8d8a36ef323fe7e2f7ff580e382557..4acf0870bbcc8390ecacaf466294e15bb102375f 100644 --- a/buildheader/tdb.h +++ b/buildheader/tdb.h @@ -55,6 +55,7 @@ struct __toku_loader { int (*abort)(DB_LOADER *loader); /* abort loading, free memory */ }; typedef struct __toku_engine_status { + char creationtime[26]; /* time of environment creation */ char startuptime[26]; /* time of engine startup */ char now[26]; /* time of engine status query (i.e. now) */ u_int64_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ @@ -146,6 +147,10 @@ typedef struct __toku_engine_status { u_int64_t upgrade_header; /* how many brt headers were upgraded? */ u_int64_t upgrade_nonleaf; /* how many brt nonleaf nodes were upgraded? */ u_int64_t upgrade_leaf; /* how many brt leaf nodes were upgraded? */ + u_int64_t original_ver; /* original environment version */ + u_int64_t ver_at_startup; /* environment version at startup */ + u_int64_t last_lsn_v12; /* last lsn of version 12 environment */ + char upgrade_v13_time[26]; /* timestamp of when upgrade to version 13 environment was done */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/include/db.h b/include/db.h index b75bb56d6d8d8a36ef323fe7e2f7ff580e382557..4acf0870bbcc8390ecacaf466294e15bb102375f 100644 --- a/include/db.h +++ b/include/db.h @@ -55,6 +55,7 @@ struct __toku_loader { int (*abort)(DB_LOADER *loader); /* abort loading, free memory */ }; typedef struct __toku_engine_status { + char creationtime[26]; /* time of environment creation */ char startuptime[26]; /* time of engine startup */ char now[26]; /* time of engine status query (i.e. now) */ u_int64_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ @@ -146,6 +147,10 @@ typedef struct __toku_engine_status { u_int64_t upgrade_header; /* how many brt headers were upgraded? */ u_int64_t upgrade_nonleaf; /* how many brt nonleaf nodes were upgraded? */ u_int64_t upgrade_leaf; /* how many brt leaf nodes were upgraded? */ + u_int64_t original_ver; /* original environment version */ + u_int64_t ver_at_startup; /* environment version at startup */ + u_int64_t last_lsn_v12; /* last lsn of version 12 environment */ + char upgrade_v13_time[26]; /* timestamp of when upgrade to version 13 environment was done */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/src/ydb.c b/src/ydb.c index 11f933816a8c615a3dcfe7796856aeb572446ba7..d432cfdf812ff61a6e52557df6e2638582cb0eec 100644 --- a/src/ydb.c +++ b/src/ydb.c @@ -430,7 +430,7 @@ static const char * curr_env_ver_key = "current_version"; // Following keys added in version 13 static const char * creation_time_key = "creation_time"; static const char * last_lsn_of_v12_key = "last_lsn_of_v12"; -static const char * upgrade_13_time_key = "upgrade_13_time"; // Add more keys for future upgrades +static const char * upgrade_v13_time_key = "upgrade_v13_time"; // Add more keys for future upgrades // Values read from (or written into) persistent environment, // kept here for read-only access from engine status. @@ -438,7 +438,7 @@ static uint32_t persistent_original_env_version; static uint32_t persistent_stored_env_version_at_startup; // read from curr_env_ver_key, prev version as of this startup static time_t persistent_creation_time; static uint64_t persistent_last_lsn_of_v12; -static time_t persistent_upgrade_13_time; +static time_t persistent_upgrade_v13_time; // Requires: persistent environment dictionary is already open. // Input arg is lsn of clean shutdown of previous version, @@ -472,9 +472,9 @@ maybe_upgrade_persistent_environment_dictionary(DB_ENV * env, DB_TXN * txn, LSN r = toku_db_put(persistent_environment, txn, &key, &val, DB_YESOVERWRITE); assert(r==0); - time_t upgrade_13_time_d = toku_htod64(time(NULL)); - toku_fill_dbt(&key, upgrade_13_time_key, strlen(upgrade_13_time_key)); - toku_fill_dbt(&val, &upgrade_13_time_d, sizeof(upgrade_13_time_d)); + time_t upgrade_v13_time_d = toku_htod64(time(NULL)); + toku_fill_dbt(&key, upgrade_v13_time_key, strlen(upgrade_v13_time_key)); + toku_fill_dbt(&val, &upgrade_v13_time_d, sizeof(upgrade_v13_time_d)); r = toku_db_put(persistent_environment, txn, &key, &val, DB_NOOVERWRITE); assert(r==0); } @@ -521,11 +521,11 @@ capture_persistent_env (DB_ENV * env, DB_TXN * txn) { assert(r == 0); persistent_last_lsn_of_v12 = toku_dtoh64(*(uint32_t*)val.data); - toku_fill_dbt(&key, upgrade_13_time_key, strlen(upgrade_13_time_key)); + toku_fill_dbt(&key, upgrade_v13_time_key, strlen(upgrade_v13_time_key)); toku_init_dbt(&val); r = toku_db_get(persistent_environment, txn, &key, &val, 0); assert(r == 0); - persistent_upgrade_13_time = toku_dtoh64((*(time_t*)val.data)); + persistent_upgrade_v13_time = toku_dtoh64((*(time_t*)val.data)); } } @@ -1630,6 +1630,7 @@ env_get_engine_status(DB_ENV * env, ENGINE_STATUS * engstat) { int r = 0; if (!env_opened(env)) r = EINVAL; else { + format_time(&persistent_creation_time, engstat->creationtime); time_t now = time(NULL); format_time(&now, engstat->now); format_time(&startuptime, engstat->startuptime); @@ -1784,6 +1785,10 @@ env_get_engine_status(DB_ENV * env, ENGINE_STATUS * engstat) { engstat->upgrade_header = brt_upgrade_stat.header_12; engstat->upgrade_nonleaf = brt_upgrade_stat.nonleaf_12; engstat->upgrade_leaf = brt_upgrade_stat.leaf_12; + engstat->original_ver = persistent_original_env_version; + engstat->ver_at_startup = persistent_stored_env_version_at_startup; + engstat->last_lsn_v12 = persistent_last_lsn_of_v12; + format_time(&persistent_upgrade_v13_time, engstat->upgrade_v13_time); } } return r; @@ -1797,6 +1802,7 @@ env_get_engine_status_text(DB_ENV * env, char * buff, int bufsiz) { int r = env_get_engine_status(env, &engstat); int n = 0; // number of characters printed so far + n += snprintf(buff + n, bufsiz - n, "creationtime %s \n", engstat.creationtime); n += snprintf(buff + n, bufsiz - n, "startuptime %s \n", engstat.startuptime); n += snprintf(buff + n, bufsiz - n, "now %s \n", engstat.now); n += snprintf(buff + n, bufsiz - n, "ydb_lock_ctr %"PRIu64"\n", engstat.ydb_lock_ctr); @@ -1887,6 +1893,11 @@ env_get_engine_status_text(DB_ENV * env, char * buff, int bufsiz) { n += snprintf(buff + n, bufsiz - n, "upgrade_header %"PRIu64"\n", engstat.upgrade_header); n += snprintf(buff + n, bufsiz - n, "upgrade_nonleaf %"PRIu64"\n", engstat.upgrade_nonleaf); n += snprintf(buff + n, bufsiz - n, "upgrade_leaf %"PRIu64"\n", engstat.upgrade_leaf); + n += snprintf(buff + n, bufsiz - n, "original_ver %"PRIu64"\n", engstat.original_ver); + n += snprintf(buff + n, bufsiz - n, "ver_at_startup %"PRIu64"\n", engstat.ver_at_startup); + n += snprintf(buff + n, bufsiz - n, "last_lsn_v12 %"PRIu64"\n", engstat.last_lsn_v12); + n += snprintf(buff + n, bufsiz - n, "upgrade_v13_time %s \n", engstat.upgrade_v13_time); + if (n > bufsiz) { char * errmsg = "BUFFER TOO SMALL\n"; int len = strlen(errmsg) + 1;