Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/) et ce pr

## [Unreleased]

## [4.1.0] - 2026-06-29

### Fixed
- `Storage` : on attend uniquement entre deux tentatives de lecture ou d'écriture, et pas après la dernière tentative.

### Changed

- `Level` : on n'essaye même pas de faire la lecture d'une tuile si on est hors limite (éviter des 404 prévisibles)

## [4.0.0] - 2026-06-26

### Changed
Expand Down Expand Up @@ -232,7 +241,8 @@ Les librairies sont gérées de manière indépendantes, conditionnées pour êt

[1.0.3]: https://github.com/rok4/core-cpp/releases/tag/1.0.3

[Unreleased]: https://github.com/rok4/core-cpp/compare/4.0.0...HEAD
[Unreleased]: https://github.com/rok4/core-cpp/compare/4.1.0...HEAD
[4.1.0]: https://github.com/rok4/core-cpp/compare/4.0.0...4.1.0
[4.0.0]: https://github.com/rok4/core-cpp/compare/3.1.0...4.0.0
[3.1.0]: https://github.com/rok4/core-cpp/compare/3.0.0...3.1.0

Expand Down
60 changes: 45 additions & 15 deletions src/storage/S3Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ int S3Context::read(uint8_t *data, int offset, int size, std::string name) {
BOOST_LOG_TRIVIAL(debug) << "S3 read : " << size << " bytes (from the " << offset << " one) in the object " << bucket_name << "@" << ((cluster_name != "") ? cluster_name : host) << " / " << name;

int attempt = 1;
while (attempt <= read_attempts) {
while (attempt) {
// On constitue le moyen de récupération des informations (avec les structures de LibcurlStruct)

CURLcode res;
Expand Down Expand Up @@ -360,8 +360,13 @@ int S3Context::read(uint8_t *data, int offset, int size, std::string name) {
BOOST_LOG_TRIVIAL(error) << "Try " << attempt << " failed" ;
BOOST_LOG_TRIVIAL(error) << curl_easy_strerror(res);
attempt++;
sleep(waiting_time);
continue;

if (attempt > read_attempts) {
break;
} else {
sleep(waiting_time);
continue;
}
}

long http_code = 0;
Expand All @@ -370,8 +375,13 @@ int S3Context::read(uint8_t *data, int offset, int size, std::string name) {
BOOST_LOG_TRIVIAL(error) << "Try " << attempt << " failed" ;
BOOST_LOG_TRIVIAL(error) << "Response HTTP code : " << http_code;
attempt++;
sleep(waiting_time);
continue;

if (attempt > read_attempts) {
break;
} else {
sleep(waiting_time);
continue;
}
}

memcpy(data, chunk.data, chunk.size);
Expand All @@ -391,7 +401,7 @@ uint8_t *S3Context::read_full(int &size, std::string name) {
// On constitue le moyen de récupération des informations (avec les structures de LibcurlStruct)

int attempt = 1;
while (attempt <= read_attempts) {
while (attempt) {
CURLcode res;
struct curl_slist *list = NULL;
DataStruct chunk;
Expand Down Expand Up @@ -463,8 +473,13 @@ uint8_t *S3Context::read_full(int &size, std::string name) {
BOOST_LOG_TRIVIAL(error) << "Try " << attempt << " failed" ;
BOOST_LOG_TRIVIAL(error) << curl_easy_strerror(res);
attempt++;
sleep(waiting_time);
continue;

if (attempt > read_attempts) {
break;
} else {
sleep(waiting_time);
continue;
}
}

long http_code = 0;
Expand All @@ -473,8 +488,13 @@ uint8_t *S3Context::read_full(int &size, std::string name) {
BOOST_LOG_TRIVIAL(error) << "Try " << attempt << " failed" ;
BOOST_LOG_TRIVIAL(error) << "Response HTTP code : " << http_code;
attempt++;
sleep(waiting_time);
continue;

if (attempt > read_attempts) {
break;
} else {
sleep(waiting_time);
continue;
}
}

size = chunk.size;
Expand Down Expand Up @@ -574,7 +594,7 @@ bool S3Context::close_to_write(std::string name) {
BOOST_LOG_TRIVIAL(debug) << "Write buffered " << it1->second->size() << " bytes in the S3 object " << name;

int attempt = 1;
while (attempt <= write_attempts) {
while (attempt) {

CURLcode res;
struct curl_slist *list = NULL;
Expand Down Expand Up @@ -645,8 +665,13 @@ bool S3Context::close_to_write(std::string name) {
BOOST_LOG_TRIVIAL(error) << "Try " << attempt << " failed" ;
BOOST_LOG_TRIVIAL(error) << curl_easy_strerror(res);
attempt++;
sleep(waiting_time);
continue;

if (attempt > write_attempts) {
break;
} else {
sleep(waiting_time);
continue;
}
}

long http_code = 0;
Expand All @@ -655,8 +680,13 @@ bool S3Context::close_to_write(std::string name) {
BOOST_LOG_TRIVIAL(error) << "Try " << attempt << " failed" ;
BOOST_LOG_TRIVIAL(error) << "Response HTTP code : " << http_code;
attempt++;
sleep(waiting_time);
continue;

if (attempt > write_attempts) {
break;
} else {
sleep(waiting_time);
continue;
}
}

BOOST_LOG_TRIVIAL(debug) << "Erase the flushed buffer";
Expand Down
60 changes: 47 additions & 13 deletions src/storage/SwiftContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ int SwiftContext::read(uint8_t* data, int offset, int size, std::string name) {

int attempt = 1;
bool reconnection = false;
while (attempt <= read_attempts) {
while (attempt) {

CURLcode res;
struct curl_slist *list = NULL;
Expand Down Expand Up @@ -347,7 +347,14 @@ int SwiftContext::read(uint8_t* data, int offset, int size, std::string name) {
if( CURLE_OK != res) {
BOOST_LOG_TRIVIAL(error) << "Cannot read data from Swift : " << size << " bytes (from the " << offset << " one) in the object " << name;
BOOST_LOG_TRIVIAL(error) << curl_easy_strerror(res);
return -1;
attempt++;

if (attempt > write_attempts) {
break;
} else {
sleep(waiting_time);
continue;
}
}

long http_code = 0;
Expand All @@ -373,8 +380,13 @@ int SwiftContext::read(uint8_t* data, int offset, int size, std::string name) {
BOOST_LOG_TRIVIAL(error) << "Try " << attempt << " failed" ;
BOOST_LOG_TRIVIAL(error) << "Response HTTP code : " << http_code;
attempt++;
sleep(waiting_time);
continue;

if (attempt > read_attempts) {
break;
} else {
sleep(waiting_time);
continue;
}
}

memcpy(data, chunk.data, chunk.size);
Expand All @@ -399,7 +411,7 @@ uint8_t* SwiftContext::read_full(int& size, std::string name) {

int attempt = 1;
bool reconnection = false;
while (attempt <= read_attempts) {
while (attempt) {

CURLcode res;
struct curl_slist *list = NULL;
Expand Down Expand Up @@ -437,7 +449,14 @@ uint8_t* SwiftContext::read_full(int& size, std::string name) {
if( CURLE_OK != res) {
BOOST_LOG_TRIVIAL(error) << "Cannot read full object from Swift : " << name;
BOOST_LOG_TRIVIAL(error) << curl_easy_strerror(res);
return NULL;
attempt++;

if (attempt > write_attempts) {
break;
} else {
sleep(waiting_time);
continue;
}
}

long http_code = 0;
Expand All @@ -463,8 +482,13 @@ uint8_t* SwiftContext::read_full(int& size, std::string name) {
BOOST_LOG_TRIVIAL(error) << "Try " << attempt << " failed" ;
BOOST_LOG_TRIVIAL(error) << "Response HTTP code : " << http_code;
attempt++;
sleep(waiting_time);
continue;

if (attempt > read_attempts) {
break;
} else {
sleep(waiting_time);
continue;
}
}

uint8_t* data = new uint8_t[chunk.size];
Expand Down Expand Up @@ -559,7 +583,7 @@ bool SwiftContext::close_to_write(std::string name) {

int attempt = 1;
bool reconnection = false;
while (attempt <= write_attempts) {
while (attempt) {
CURLcode res;
struct curl_slist *list = NULL;
CURL* curl = CurlPool::get_curl_env();
Expand Down Expand Up @@ -592,8 +616,13 @@ bool SwiftContext::close_to_write(std::string name) {
BOOST_LOG_TRIVIAL(error) << "Try " << attempt << " failed" ;
BOOST_LOG_TRIVIAL(error) << curl_easy_strerror(res);
attempt++;
sleep(waiting_time);
continue;

if (attempt > write_attempts) {
break;
} else {
sleep(waiting_time);
continue;
}
}

long http_code = 0;
Expand All @@ -620,8 +649,13 @@ bool SwiftContext::close_to_write(std::string name) {
BOOST_LOG_TRIVIAL(error) << "Try " << attempt << " failed" ;
BOOST_LOG_TRIVIAL(error) << "Response HTTP code : " << http_code;
attempt++;
sleep(waiting_time);
continue;

if (attempt > write_attempts) {
break;
} else {
sleep(waiting_time);
continue;
}
}

BOOST_LOG_TRIVIAL(debug) << "Erase the flushed buffer";
Expand Down
27 changes: 21 additions & 6 deletions src/storage/ceph/CephPoolContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int CephPoolContext::read(uint8_t* data, int offset, int size, std::string name)
int readSize;
int attempt = 1;
bool error = false;
while(attempt <= read_attempts) {
while(attempt) {
readSize = rados_read(io_ctx, name.c_str(), (char*) data, size, offset);

if (readSize < 0) {
Expand All @@ -154,7 +154,12 @@ int CephPoolContext::read(uint8_t* data, int offset, int size, std::string name)
}

attempt++;
sleep(waiting_time);

if (attempt > read_attempts) {
break;
} else {
sleep(waiting_time);
}
}

if (error) {
Expand Down Expand Up @@ -190,7 +195,7 @@ uint8_t* CephPoolContext::read_full(int& size, std::string name) {

int attempt = 1;
bool error = false;
while(attempt <= read_attempts) {
while(attempt) {
size = rados_read(io_ctx, name.c_str(), (char*) data, fullSize, 0);

if (size < 0) {
Expand All @@ -210,7 +215,12 @@ uint8_t* CephPoolContext::read_full(int& size, std::string name) {
}

attempt++;
sleep(waiting_time);

if (attempt > read_attempts) {
break;
} else {
sleep(waiting_time);
}
}

if (error) {
Expand Down Expand Up @@ -299,7 +309,7 @@ bool CephPoolContext::close_to_write(std::string name) {

bool ok = true;
int attempt = 1;
while(attempt <= write_attempts) {
while(attempt) {
int err = rados_write_full(io_ctx,name.c_str(), &((*(it1->second))[0]), it1->second->size());
if (err < 0) {
ok = false;
Expand All @@ -312,7 +322,12 @@ bool CephPoolContext::close_to_write(std::string name) {
}

attempt++;
sleep(waiting_time);

if (attempt > write_attempts) {
break;
} else {
sleep(waiting_time);
}
}

if (ok) {
Expand Down
6 changes: 6 additions & 0 deletions src/utils/Level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,12 @@ std::string Level::get_path ( int tilex, int tiley) {
*/
DataSource* Level::get_encoded_tile ( int x, int y ) { // TODO: return 0 sur des cas d'erreur..

if (!tm_limits.contain_tile(x,y)) {
// On est hors tuiles
BOOST_LOG_TRIVIAL(warning) << "get_encoded_tile out limits";
return NULL;
}

//on stocke une dalle
// Index de la tuile (cf. ordre de rangement des tuiles)
int n = ( y % tiles_per_height ) * tiles_per_width + ( x % tiles_per_width );
Expand Down
Loading