Commit Graph

20 Commits

Author SHA1 Message Date
Nathan Wallace
0a50ccf1a3 Fix #4760: State file corruption from concurrent writes in pluginmanager (#4907)
* Add test demonstrating race condition in State.Save()

Add TestStateFileRaceCondition which demonstrates the race condition
that can occur when multiple goroutines call State.Save() concurrently.
Without proper synchronization, concurrent writes to the same file can
result in corrupted JSON.

This test creates 50 concurrent goroutines each performing 20 Save()
operations to increase the likelihood of exposing the race condition.

Related to #4760

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

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

* Fix race condition in State.Save() with mutex and atomic write

Protect State.Save() with a mutex to prevent concurrent writes from
corrupting the state file. This fixes the race condition where multiple
goroutines could write to the file simultaneously, resulting in invalid
JSON.

The fix uses:
1. A package-level mutex to serialize all Save() operations
2. Atomic write pattern (write to temp file, then rename) for additional
   safety against partial writes

This ensures the state file remains valid even under high concurrency.

Fixes #4760

🤖 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-17 04:44:44 -05:00
Nathan Wallace
9d8f135805 Nil pointer dereference in State.reattachConfig() closes #4755 (#4893)
* Add test for #4755: Nil pointer dereference in State.reattachConfig()

* Fix #4755: Add nil check in State.reattachConfig()
2025-11-16 15:51:19 -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
kaidaguerre
51c5022e96 Fix pluginmanager not running error when starting steampipe via a symlink. Closes #4573 (#4574) 2025-06-12 00:01:59 +05:30
kaidaguerre
d97cacab4a Improve logging for verifyRunning (#4562) 2025-06-11 15:00:08 +05:30
kaidaguerre
30c344a4f8 Fix plugin manager verifyRunning function to avoid false positives, which lead to failure to start the plugin manager. Fixes #4507
* pluginmanager.State.verifyRunning() now checks the process corresponding to the pid is a plugin manager process
pluginmanager.State.kill() deletes the plugin manager state file even if the process is not found
2025-05-14 09:46:42 +01:00
Puskar Basu
9927cefece Fix issue where plugin start timeout was getting limited to 60s. Closes #4477 (#4493) 2025-03-31 13:00:22 +01:00
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
c5cc5a3e7a compiles and seems to work
connection state not populating
2024-09-27 18:14:28 +05:30
kai
cd07bf20f1 working on it 2024-09-27 18:13:12 +05:30
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
7feb305fde Provide mechanism for plugin manager to send warnings back to CLI. Closes #3603 (#3835) 2023-09-13 15:34:15 +01:00
Binaek Sarkar
862fcf1b71 Fix stall in plugin manager shutdown. Closes #3817 2023-09-08 17:48:20 +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
kai
48a08fed43 Cleanup temp plugin file for plugin manager. Closes #3292 2023-05-19 16:06:48 +01:00
kaidaguerre
7703975883 Refactor/fix connection and plugin validation during refreshConnections - ensure failed connections are set to 'error' in connection state. Closes #3432 2023-05-17 14:43:27 +01:00
kaidaguerre
40804a3201 Execute RefreshConnections asyncronously and optimise for high connection count. Add connection_state table.
- Execute RefreshConnections asyncronously
- Add connection_state table to indicate the loading state of connections
- Optimise RefreshConnections by cloning connection schemas
- Add locking to ensure only a single instance of RefreshConnections runs
- Start executing queries without waiting for connections to load, add smart error handling to wait for required connection
- Optimise autocomplete for high connection count
- Autocomplete and inspect data available before all conections are refreshed
- Update file watcher to respond to CHMOD, so thaat it pickes up deletion of file contents

 Closes #3394
 Closes #3267
2023-05-10 09:05:08 +01:00