Commit Graph

10 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
da2f3ecc03 Upgrade to pipe-fittings v2, go-kit v1 (#4485) 2025-03-06 16:34:18 +05:30
kai
cd07bf20f1 working on it 2024-09-27 18:13:12 +05:30
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
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