Commit Graph

23 Commits

Author SHA1 Message Date
Puskar Basu
3f4eaae1a8 Fix db client deadlocks with non-blocking cleanup and RW locks (#4918) 2025-12-16 21:19:27 +05:30
Nathan Wallace
96d346ae5b HandlePluginLimiterChanges nil pool handling closes #4785 (#4877)
* Add test demonstrating bug #4785 - HandlePluginLimiterChanges panics with nil pool

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com)

* Fix #4785: Add nil pool check in refreshRateLimiterTable

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-16 11:09:57 -05:00
Nathan Wallace
4f1367fe6c Race condition in updateRateLimiterStatus closes #4786 (#4830)
* Add test demonstrating bug #4786 - race in updateRateLimiterStatus

Test demonstrates the race condition when updateRateLimiterStatus reads
from the userLimiters map without holding a lock, while another goroutine
concurrently writes to the map.

Running with -race flag shows data races at:
- plugin_manager_rate_limiters.go:176 (read in getUserDefinedLimitersForPlugin)
- plugin_manager_rate_limiters.go:161 (read in updateRateLimiterStatus)
- rate_limiters_test.go:40 (concurrent write)

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4786: Protect updateRateLimiterStatus with RWMutex

Add RWMutex write lock protection to updateRateLimiterStatus to prevent
race conditions when the method reads from userLimiters map and writes to
pluginLimiter.Status fields while other goroutines concurrently modify these
data structures.

The fix uses m.mut.Lock() (not RLock) because the method modifies the
pluginLimiter.Status field, requiring exclusive write access.

Note: This fix assumes updateRateLimiterStatus is not called from within
a context that already holds the mutex. If it is, additional refactoring
will be needed to prevent deadlock.

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix deadlock in updateRateLimiterStatus

The previous fix introduced a deadlock where updateRateLimiterStatus() would:
1. Acquire m.mut.Lock()
2. Call getUserDefinedLimitersForPlugin()
3. Which tries to acquire m.mut.RLock() - deadlock!

Go mutexes cannot acquire RLock when the same goroutine already holds Lock.

Fix by refactoring into internal/public pattern:
- getUserDefinedLimitersForPlugin() - public, acquires RLock
- getUserDefinedLimitersForPluginInternal() - internal, no lock (caller must hold it)
- updateRateLimiterStatus() now calls internal version while holding lock

Test verification: TestPluginManager_UpdateRateLimiterStatus_NoOverride
- Before: Timeout after 28s
- After: Pass in 0.429s

Fixes #4786

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 11:47:09 -05:00
Nathan Wallace
7a1533bd4f Race condition in rate limiter map access closes #4799 (#4843)
* Add test for #4799: Race condition in rate limiter map access

This test demonstrates the race condition in getUserDefinedLimitersForPlugin
where the userLimiters map is read without mutex protection while being
concurrently written by other goroutines.

Run with: go test -race -v -run TestPluginManager_ConcurrentRateLimiterMapAccess ./pkg/pluginmanager_service

* Fix #4799: Add mutex protection for rate limiter map access

Protected all accesses to m.userLimiters map with RWMutex:
- getUserDefinedLimitersForPlugin: Added RLock for map read
- getPluginsWithChangedLimiters: Added RLock for map iteration
- handleUserLimiterChanges: Added Lock for map write
- refreshRateLimiterTable: Added RLock for map iteration
- setRateLimiters: Added RLock for map read

This prevents data races when the map is concurrently read and written
by multiple goroutines.
2025-11-15 10:48:09 -05:00
Puskar Basu
e19d35c457 chore: update module to v2 and bump Go version to 1.24 (#4597) 2025-07-07 16:03:56 +05:30
Puskar Basu
96959081b0 Added RateLimiterFromProto and RateLimiterasProto (#4500) 2025-03-12 22:14:14 +05:30
Puskar Basu
da2f3ecc03 Upgrade to pipe-fittings v2, go-kit v1 (#4485) 2025-03-06 16:34:18 +05:30
kai
112647bae0 tidy 2024-10-15 11:44:13 +01:00
kai
cb681c67cc compiles but needs testing 2024-09-27 18:14:28 +05:30
kai
80ad514e1d steampipe compiles 2024-09-27 18:14:28 +05:30
kai
fd94b2e2ec working on it 2024-09-27 18:14:25 +05:30
kai
cd07bf20f1 working on it 2024-09-27 18:13:12 +05:30
kai
faead86d26 move stuff to pipe-fittings 2024-09-27 18:13:12 +05:30
kaidaguerre
43540d318c Add support for nested dashboards. Closes #4208 2024-03-20 15:58:57 +00:00
kaidaguerre
12079986d5 Add steampipe_plugin_column introspection table to internal schema. Closes #4003 2023-11-29 12:49:12 +00:00
Puskar Basu
2438a122a6 Fixes issue where initialising rate limiter definitions was taking too long due to force recreation of tables. Closes #3902 2023-09-26 14:48:59 +01:00
kaidaguerre
235cbc2037 Connection watching fixes.
Fix ConnectionConfigMap.Diff  inconsistent usage of Plugin and PluginInstance. Closes #3895
Fix GetConnectionStateErrorSql returning invalid query with additional parameter. Closes #3896
Update FDW to v1.8.0-rc.11 - fix failure to load connection config when importing schema
2023-09-25 12:35:00 +01:00
kaidaguerre
6f051ea463 Do not add connections in error to plugin manager connection map. Closes #3893 2023-09-22 18:12:29 +01:00
kaidaguerre
79606c5bcd Rename internal introspection tables. Fix warning notifications from RefreshConnections. Improve error handlingh for config inconsistencies in conneciton and plugin config. Closes #3886 2023-09-22 16:02:41 +01:00
kaidaguerre
f232b14f06 Add support for multiple instances of the same plugin version to execute. Closes #3863 2023-09-18 15:39:17 +01:00
kaidaguerre
95fed2ed2a Key the rate limiter and plugin config maps by plugin image ref, not short name. Closes #3820 2023-09-11 15:56:35 +01:00
kaidaguerre
f041597497 Add support for plugin connection config and options blocks. Add options and env var configuration of max memory. Closes #3807 2023-09-06 15:59:13 +01:00
kaidaguerre
2a86d08445 Add support to retrieve plugin rate limiter definitions and use to populate steampipe_rate_limiter table. Closes #3805 (#3803) 2023-09-06 13:28:22 +01:00