Repository navigation
refactor(core): improve backend storage robustness, error handling, and unit test coverage - #535
Merged
hummeltech merged 7 commits intoOct 31, 2026
Conversation
|
|
||
| memcached_xyzo_to_storagekey(xmlconfig, options, x, y, z, meta_path); | ||
| buf_raw = memcached_get(store->storage_ctx, meta_path, strlen(meta_path), &len, &flags, &rc); | ||
| buf_raw = memcached_get((memcached_st *)store->storage_ctx, meta_path, strlen(meta_path), &len, &flags, &rc); |
|
|
||
| memcached_xyzo_to_storagekey(xmlconfig, options, x, y, z, meta_path); | ||
| buf = memcached_get(store->storage_ctx, meta_path, strlen(meta_path), &len, &flags, &rc); | ||
| buf = memcached_get((memcached_st *)store->storage_ctx, meta_path, strlen(meta_path), &len, &flags, &rc); |
| snprintf(meta_path, PATH_MAX - 1, "%s/%d/%d/%d.meta", xmlconfig, x, y, z); | ||
|
|
||
| rc = memcached_set(store->storage_ctx, meta_path, strlen(meta_path), buf2, sz2, (time_t)0, (uint32_t)0); | ||
| rc = memcached_set((memcached_st *)store->storage_ctx, meta_path, strlen(meta_path), buf2, sz2, (time_t)0, (uint32_t)0); |
| memcached_xyz_to_storagekey(xmlconfig, x, y, z, meta_path); | ||
|
|
||
| rc = memcached_delete(store->storage_ctx, meta_path, strlen(meta_path), 0); | ||
| rc = memcached_delete((memcached_st *)store->storage_ctx, meta_path, strlen(meta_path), 0); |
| //TODO: deal with options | ||
| memcached_xyz_to_storagekey(xmlconfig, x, y, z, meta_path); | ||
| buf = memcached_get(store->storage_ctx, meta_path, strlen(meta_path), &len, &flags, &rc); | ||
| buf = memcached_get((memcached_st *)store->storage_ctx, meta_path, strlen(meta_path), &len, &flags, &rc); |
| // memcached_get() does not return a CAS value, so a compare-and-swap cannot be used here | ||
| // (the previous code passed an uninitialised CAS token). Replace the existing item instead. | ||
| rc = memcached_replace(store->storage_ctx, meta_path, strlen(meta_path), buf, len, 0, flags); | ||
| rc = memcached_replace((memcached_st *)store->storage_ctx, meta_path, strlen(meta_path), buf, len, 0, flags); |
| } | ||
|
|
||
| connection_string_primary = malloc(strlen(connection_string) - strlen("composite:{") - strlen(connection_string_secondary) + 1); | ||
| connection_string_primary = (char *)malloc(strlen(connection_string) - strlen("composite:{") - strlen(connection_string_secondary) + 1); |
| } | ||
|
|
||
| connection_string_primary = malloc(strlen(connection_string) - strlen("composite:{") - strlen(connection_string_secondary) + 1); | ||
| connection_string_primary = (char *)malloc(strlen(connection_string) - strlen("composite:{") - strlen(connection_string_secondary) + 1); |
- Export display_rate() via render_submit_queue.h and remove duplicate definitions across render_expired, render_list, render_old, and render_speedtest. - Add Catch2 unit test coverage for display_rate formatting and log output.
Remove unused file-scope static variable max_load and make it local to main(). The load limit is passed directly to spawn_workers(), which manages load throttling via render_submit_queue. Also remove unneeded sys_utils.h inclusion.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #535 +/- ##
==========================================
+ Coverage 81.54% 89.58% +8.04%
==========================================
Files 24 24
Lines 5645 5463 -182
==========================================
+ Hits 4603 4894 +291
+ Misses 1042 569 -473 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Ensure finish_workers() is invoked in unit_test_render_submit_queue.cpp to prevent thread race conditions when verifying error logs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refactors core backend components across queue handling, socket protocol helpers, and storage backends (
store_file,store_memcached,store_rados,store_ro_composite,store_ro_http_proxy). The primary goals are to eliminate static symbols/naming collisions, strengthen error checking, fix memory allocation edge cases, and significantly expand test harness capabilities and overall unit test coverage.Key Changes
1. Queue & Worker Management (
render_submit_queue,request_queue)qItem,speed_stat,speed_stats) and function prototypes (check_load,thread_main) inrender_submit_queue.hto enable direct unit testing.enqueue()to prevent leaks on allocation failures.make_connection()to output human-readable socket error strings viagai_strerror().(struct request_queue *)calloc) for C++ compilation cleanliness.display_rate()viarender_submit_queue.hand remove duplicate definitions acrossrender_expired,render_list,render_old, andrender_speedtest.2. Storage Backends & Thread Safety (
store_*)store_rados: Renamed file-scopeqLocktorados_qLockto prevent symbol collisions across backends. Added NULL safety validation checks forctxandctx->iobefore executing Rados read/write/delete/expire/close operations.store_ro_composite: Renamed internaltile_cachestruct tostore_ro_composite_tile_cacheto resolve name clashes. Added Cairo surface status checks (cairo_surface_status) to safely handle PNG decoding errors and destroy intermediate surfaces without leaks.store_ro_http_proxy: Renamed file-scopeqLocktoro_http_proxy_mutexandtile_cachetoro_http_proxy_tile_cache. Added heap allocation failure checks when allocating path buffers.store_memcached: Added explicit casts forstore->storage_ctxto(memcached_st *)across read, stat, write, and delete routines.3. Protocol Helpers & Defensive Checks (
protocol_helper,parameterize_style)send_cmd()to reject negative file descriptors before attempting socket operations, and validated socket types viagetsockopt(..., SO_TYPE, ...).function_nameininit_parameterization_function()to avoid segfaults when evaluating empty parameterizations.4. Test Suite & Coverage Expansion (
tests/)request_queue,render_submit_queue, protocol helpers, tile expiration, and storage backends (store_file,store_memcached,store_rados,store_ro_composite,store_ro_http_proxy,store_null).STORE_LIBRARIESinto theunit_testsexecutable and register regular expression checks for timestamp verifications.LCOV_EXCL_START/LCOV_EXCL_STOPmarkers for accurate lcov reporting.Testing & Verification
unit_tests).build-and-test.yml).