wrong unix timestamp calculation in hadoop lib
PATCH 1/1 wrong unix timestamp calculation in hadoop lib
From: Andrey Stepachev <[email protected]>
Hadoop always see wrong dates due of wrong timestamp calculation. Possibly fixes #1666.
--- src/client/hadoop/CephFSInterface.cc | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
src/client/hadoop/CephFSInterface.cc +4 -4
@@ -672,14 +672,14 @@ JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1stat env->SetBooleanField(j_stat, c_dir_id, (0 != S_ISDIR(st.st_mode))); env->SetLongField(j_stat, c_block_id, st.st_blksize); - long long java_mtime(st.st_mtime); + long long java_mtime(st.st_mtim.tv_sec); java_mtime *= 1000; - java_mtime += st.st_mtim.tv_nsec; + java_mtime += st.st_mtim.tv_nsec / 1000; env->SetLongField(j_stat, c_mod_id, java_mtime); - long long java_atime(st.st_atime); + long long java_atime(st.st_atim.tv_sec); java_atime *= 1000; - java_atime += st.st_atim.tv_nsec; + java_atime += st.st_atim.tv_nsec / 1000; env->SetLongField(j_stat, c_access_id, java_atime); env->SetIntField(j_stat, c_mode_id, (int)st.st_mode);
Signature · 1 line
1.7.5.4
Quoted 4 lines · Andrey Stepachev
From: Andrey Stepachev <[email protected]>
Hadoop always see wrong dates due of wrong timestamp calculation. Possibly fixes #1666.
Using coarse-grained timestamps might mask the problem in 1666. But it would only work in certain circumstances such as when clock sync skew is sufficiently small, and I think edge conditions would continue to exist. A more robust solution is probably needed for #1666 :(
Quoted 8 lines
Signed-off-by Andrey Stepachev <[email protected]>---
src/client/hadoop/CephFSInterface.cc | 8 ++++----1 files changed, 4 insertions(+), 4 deletions(-)- long long
java_mtime(st.st_mtime);
+ long longjava_mtime(st.st_mtim.tv_sec);
mtime vs mtim: the later is non-portable?
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAB2gnbVFEasWwccsj7FhffuOG3cxOC18u-oNzDtXhoF=iXVx1A@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CAADCt4Lm91UdEiZUoBD7LTK33BDEZJMJNqcGmrZy81tP+nxy3g@mail.gmail.com
Quoted 22 lines · Andrey Stepachev
2012/1/14 Noah Watkins <[email protected]>:
Quoted 10 lines · Andrey Stepachev
Quoted 4 lines
From: Andrey Stepachev <[email protected]>
Hadoop always see wrong dates due of wrong timestamp calculation. Possibly fixes #1666.
Using coarse-grained timestamps might mask the problem in 1666. But it would only work in certain circumstances such as when clock sync skew is sufficiently small, and I think edge conditions would continue to exist.
No. It is really bug. Not a coarse grained solution. Here is really bug, because if we don't divide we get not milliseconds, we'll got seconds. In my test environment i have time difference up to several hours.
Java uses millis, so we must divide nanos to get millis.
java_mtime+= st.st_mtim.tv_nsec / 1000;Quoted 1 line
A more robust solution is probably needed for #1666 :(
Quoted 7 lines
How about new function
ceph_lstat_nocache, which in turn will call lstat with flags == 0. In that case_get_attralways will query MDS (if I understand code, but I can be wrong). It is a performance hit, but hadoop should work.
We can ever do lstat twice and get the biggest mtime.
Yeh, we need some way to refresh the cached stats at the client (if i remember 1666 correctly). If you are running into this issue there is a small hack for Hadoop that you an apply (it's on the wiki) until something for 1666 is figured out. By the way, these JNI wrappers are being rewritten to be Hadoop agnostic (pure libcephfs), and the code is at github.com/noahdesu/java-cephfs -- I was just getting ready to port the stat code, so it is nice you brought this issue back up :)
Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
Signed-off-by Andrey Stepachev <[email protected]>Quoted 8 lines
Quoted 6 lines
---
src/client/hadoop/CephFSInterface.cc | 8 ++++----1 files changed, 4 insertions(+), 4 deletions(-)- long long
java_mtime(st.st_mtime);
+ long longjava_mtime(st.st_mtim.tv_sec);mtime vs mtim: the later is non-portable?
Yeah. Yes. This can be safely removed from patch.
Quoted 1 line
Quoted 6 lines
Quoted 1 line
-Noah
--
Андрей.
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
I pulled this patch into master. Thanks, Andrey!
Quoted 31 lines · Noah Watkins
Quoted 22 lines · Andrey Stepachev
2012/1/14 Noah Watkins <[email protected]>:
Quoted 10 lines · Andrey Stepachev
Quoted 4 lines
From: Andrey Stepachev <[email protected]>
Hadoop always see wrong dates due of wrong timestamp calculation. Possibly fixes #1666.
Using coarse-grained timestamps might mask the problem in 1666. But it would only work in certain circumstances such as when clock sync skew is sufficiently small, and I think edge conditions would continue to exist.
No. It is really bug. Not a coarse grained solution. Here is really bug, because if we don't divide we get not milliseconds, we'll got seconds. In my test environment i have time difference up to several hours.
Java uses millis, so we must divide nanos to get millis.
java_mtime+= st.st_mtim.tv_nsec / 1000;Quoted 1 line
A more robust solution is probably needed for #1666 :(
Quoted 7 lines
How about new function
ceph_lstat_nocache, which in turn will call lstat with flags == 0. In that case_get_attralways will query MDS (if I understand code, but I can be wrong). It is a performance hit, but hadoop should work.
We can ever do lstat twice and get the biggest mtime.
Quoted 23 lines
Yeh, we need some way to refresh the cached stats at the client (if i remember 1666 correctly). If you are running into this issue there is a small hack for Hadoop that you an apply (it's on the wiki) until something for 1666 is figured out. By the way, these JNI wrappers are being rewritten to be Hadoop agnostic (pure libcephfs), and the code is at github.com/noahdesu/java-cephfs -- I was just getting ready to port the stat code, so it is nice you brought this issue back up :)
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
Signed-off-by Andrey Stepachev <[email protected]>Quoted 8 lines
Quoted 6 lines
---
src/client/hadoop/CephFSInterface.cc | 8 ++++----1 files changed, 4 insertions(+), 4 deletions(-)- long long
java_mtime(st.st_mtime);
+ long longjava_mtime(st.st_mtim.tv_sec);mtime vs mtim: the later is non-portable?
Yeah. Yes. This can be safely removed from patch.
Is this something I should fix? It's presumably not a big problem since the older code had references to "tv_mtim", but I'm not too familiar with the history of *nix structs...
-Greg
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
2012/1/18 Gregory Farnum <[email protected]>:
Quoted 54 lines
I pulled this patch into master. Thanks, Andrey!
Quoted 51 lines · Noah Watkins
Quoted 22 lines · Andrey Stepachev
2012/1/14 Noah Watkins <[email protected]>:
Quoted 10 lines · Andrey Stepachev
Quoted 4 lines
From: Andrey Stepachev <[email protected]>
Hadoop always see wrong dates due of wrong timestamp calculation. Possibly fixes #1666.
Using coarse-grained timestamps might mask the problem in 1666. But it would only work in certain circumstances such as when clock sync skew is sufficiently small, and I think edge conditions would continue to exist.
No. It is really bug. Not a coarse grained solution. Here is really bug, because if we don't divide we get not milliseconds, we'll got seconds. In my test environment i have time difference up to several hours.
Java uses millis, so we must divide nanos to get millis.
java_mtime+= st.st_mtim.tv_nsec / 1000;Quoted 1 line
A more robust solution is probably needed for #1666 :(
Quoted 7 lines
How about new function
ceph_lstat_nocache, which in turn will call lstat with flags == 0. In that case_get_attralways will query MDS (if I understand code, but I can be wrong). It is a performance hit, but hadoop should work.
We can ever do lstat twice and get the biggest mtime.Yeh, we need some way to refresh the cached stats at the client (if i remember 1666 correctly). If you are running into this issue there is a small hack for Hadoop that you an apply (it's on the wiki) until something for 1666 is figured out. By the way, these JNI wrappers are being rewritten to be Hadoop agnostic (pure libcephfs), and the code is at github.com/noahdesu/java-cephfs -- I was just getting ready to port the stat code, so it is nice you brought this issue back up :)
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Signed-off-by Andrey Stepachev <[email protected]>---
src/client/hadoop/CephFSInterface.cc | 8 ++++----1 files changed, 4 insertions(+), 4 deletions(-)- long long
java_mtime(st.st_mtime);
+ long longjava_mtime(st.st_mtim.tv_sec);
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
mtime vs mtim: the later is non-portable?
Yeah. Yes. This can be safely removed from patch.
Is this something I should fix? It's presumably not a big problem since the older code had references to "
tv_mtim", but I'm not too familiar with the history of *nix structs...
I'm not a big guru too, but st_atim.tv_nsec used in code, so it looks more consistent to use st_atim.tv_sec, then st_atime (which is a macro). Accroding to stat.h if we havn't st_atim, code will not compile, because we try to access st_mtim.tv_nsec.
So, I think that my original patch is preferable.
Quoted 1 line
-Greg
Signature · 5 lines
Andrey. -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html